GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - SamVerschueren/rfpify: [DEPRECATED] Promisify a result-first callback function.

BranchesTags
Open more actions menu

Latest commit

 

History

6 Commits
6 Commits

Folders and files

NameName
Last commit message
Last commit date
.editorconfig
.editorconfig
 
 
.gitattributes
.gitattributes
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
index.js
index.js
 
 
license
license
 
 
optimization-test.js
optimization-test.js
 
 
package.json
package.json
 
 
readme.md
readme.md
 
 
test.js
test.js
 
 

Repository files navigation

rfpify

Promisify a result-first callback-style function.


Deprecated in favour of pify with the errorFirst option.


Install

$ npm install --save rfpify

Usage

const rfpify = require('rfpify');

rfpify(stream.once.bind(stream))('data').then(data => {
	// handle data
});

API

rfpify(input, [promiseModule], [options])

Returns a promise wrapped version of the supplied function or module.

input

Type: function, object

Result-first callback-style function.

promiseModule

Type: function

Custom promise module to use instead of the native one.

Check out pinkie-promise if you need a tiny promise polyfill.

options

multiArgs

Type: boolean Default: false

By default, the promisified function will only return the first argument from the callback, which works fine for most APIs. Turning this on will make it return an array of all arguments from the callback, instead of just the first argument.

include

Type: array of (string|regex)

Methods in a module to promisify. Remaining methods will be left untouched.

exclude

Type: array Default: [/.+Sync$/]

Methods in a module not to promisify. Methods with names ending with 'Sync' are excluded by default.

excludeMain

Type: boolean Default: false

By default, if given module is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module.

const rfpify = require('rfpify');

function fn() {
	return true;
}

fn.method = (data, callback) => {
	setImmediate(() => {
		callback(data);
	});
};

// promisify methods but not fn()
const promiseFn = rfpify.all(fn, {excludeMain: true});

if (promiseFn()) {
	promiseFn.method('hi').then(data => {
		console.log(data);
	});
}

Related

  • pify - Promisify a callback-style function

License

MIT © Sam Verschueren

About

[DEPRECATED] Promisify a result-first callback function.

Resources

Readme
MIT license
Activity

Stars

10 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.