Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proxmis

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proxmis

A generator for creating promises that can be used as node.js callbacks.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-81.82%
Maintainers
1
Weekly downloads
 
Created
Source

Proxmis.js

Proxmis is a very simple library to generate promises that can be used directly as typical two argument, error first, node.js callbacks.

##Node.js

To install:

npm install proxmis

To use:

var proxmis = require('proxmis');

##Usage

var proxmis = require('proxmis');
var fs = require('fs');
var callback = proxmis();

fs.stat('/var', callback);

callback.then(function (stats) {
	//received folder stats
});

The first argument on proxmis() can optionally be another callback to be invoked before the promise resolves, or an object containing extra options for how the promise will be resolved.

function fileStatWithCallbackOrPromise(cb) {
	var prox = proxmis(cb);
	fs.stat('/var', prox);
	return prox;
}
var prox = proxmis({noError: true});
prox('first argument resolves', 'all other arguments ignored');
prox.then(function (result) {
	// result = 'first argument resolves'
});
var prox = proxmis({allArgs: true});
prox('each argument resolves', 'together as', 'an array');
prox.then(function (result) {
	// result = ['each argument resolves', 'together as', 'an array']
});

Proxmis also provides a routine for wrapping a traditional call in a closure, directly returning a promise.

proxmis.wrap(function (callback) {
	fs.stat('/var', callback);
}).then(function (stats) {
	//received folder stats
});

Proxmis uses the ES6 Promise Polyfill to generate the promise it returns.

Keywords

FAQs

Package last updated on 28 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc