# @webreflection/lie

> An optionally sync promise that directly passes along its value

Latest version **1.0.3** (published 2024-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install @webreflection/lie
pnpm add @webreflection/lie
yarn add @webreflection/lie
bun add @webreflection/lie
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2024-06-18 |
| First published | 2020-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Andrea Giammarchi |
| Maintainers | webreflection |
| Keywords | Promise, lie, direct, sync |

## Links

- npm: https://www.npmjs.com/package/@webreflection/lie
- Repository: https://github.com/WebReflection/lie
- Homepage: https://github.com/WebReflection/lie#readme
- Issues: https://github.com/WebReflection/lie/issues
- npm.io page: https://npm.io/package/@webreflection/lie

## Recent versions

- 1.0.3 (latest) — 2024-06-18
- 1.0.2 — 2024-06-18
- 1.0.1 — 2024-06-18
- 1.0.0 — 2024-06-18
- 0.1.1 — 2020-08-04
- 0.1.0 — 2020-08-01

## README

# @webreflection/lie

An optionally sync promise that directly passes along its value, particularly useful for any *API* that handles both synchronous and asynchronous use cases through explicit `.then(...)` invocation.

```js
import lie from '@webreflection/lie';
// the lie signature:
// <T>(value: T) => Thenable<T>

lie(123)
  // invoked synchronously
  .then(value => {
    console.log('sync #1', value);
    return value * 2;
  })
  // invoked synchronously
  // because the result is an async function
  // the returned value will be a Promise this time
  .then(async value => {
    console.log('sync #2', value);
    return value * 2;
  })
  // this time is a Promise
  .then(value => {
    console.log('async #1', value);
  })
;

console.log('sync #1 and #2 already logged');
// async #1 going to be logged after
```

**Note**: a `lie(Promise.resolve(123))`, a `lie(lie(123))`, or even a `lie({ then: able })` would simply pass through as result the provided value, as opposite of creating "*lies of lies*".

---
_Source: https://npm.io/package/@webreflection/lie · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
