# node-then

> Promise aware wrapper for Node modules

Latest version **0.1.0** (published 2013-07-21) · 0 weekly downloads

## Install

```sh
npm install node-then
pnpm add node-then
yarn add node-then
bun add node-then
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2013-07-21 |
| First published | 2013-07-21 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | scothis |
| Keywords | then, promises, when.js, cujojs |

## Links

- npm: https://www.npmjs.com/package/node-then
- Repository: https://github.com/node-then/node-then
- npm.io page: https://npm.io/package/node-then

## Dependencies (1)

- [when](https://npm.io/package/when.md) ~2.2

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2013-07-21

## README

node-then
=========

[![Build Status](https://travis-ci.org/node-then/node-then.png)](https://travis-ci.org/node-then/node-then)

Thin wrapper arround Node.js modules that makes the async functions promise
aware. The wrapped methods return a promise the represents the value of the
async operation. Traditional callbacks still work, allowing for a transparent
drop-in.


Usage
-----

Wrap a single function
```javascript
var nodeThen, fs, readFileThen;

nodeThen = require('node-then');
fs = require('fs');

readFileThen = nodeThen.wrapFunction(fs.readFile, fs);

readFileThen('path/to/file').then(function (fileConent) { ... });
```

Wrap an object
```javascript
var nodeThen, fs, fsThen;

nodeThen = require('node-then');
fs = require('fs');

fsThen = nodeThen.wrapObject(fs, function isEligible(name, prop) {
	return typeof prop === 'function';
});

fsThen.readFile('path/to/file').then(function (fileConent) { ... });
```


Test Suite
----------

Our test suite uses Buster.js for correctness and Benchmark.js for performance.

Running the correctness tests:
    $ npm test

Running the performance tests:
    $ npm run-script benchmark


Performance Impact
------------------

Wrapping a callback with a promise will be slower than the native callbacks.
The question should be how much slower vs what benefit. Ultimatly, it's up to
each developer to decide if the cost/benefit is worthwhile.

```
native callback x 749 ops/sec ±0.37% (24 runs sampled)
promised callback x 697 ops/sec ±0.59% (87 runs sampled)
promised promise x 710 ops/sec ±0.59% (75 runs sampled)

promised callback is 0.084 ms slower than native callback
promised promise is 0.069 ms slower than native callback
```


Change Log
----------

v0.1.0
- first release

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