promixy

1.1.2 • Public • Published

promixy

A module help you make sync calling chain on Promise. Talk is cheap, show you the code.

Note

This module only can run in Node 6.x because it use Proxy.

Usage

Get and Apply

You can use it like:

var _ = require('promixy');
 
_({a: 12333})
  .a.toString().split('')[0].toString()
  .then(a=>+ 'yes')
  .replace('1', 'replaceStr')
  .then(console.log, console.error);

If you want get the origin promise object just use a.__promise, if you want get the calling chain just use a.__chainPath, otherwise promixy object always return a Proxy with Promise, so must attention if you want get the value of Promise, you always must use .then.

Set

You can set property value to promixy like that:

var a  = _({b: {c: 123}});
var b  = a.b;
var x = a.b.c.toString();
 
a.b.c = 456;
 
a.then(console.log, console.error);
b.then(console.log, console.error);
x.then(console.log, console.error);
 
//{ b: { c: { as: 456 } } }
//{ c: { as: 456 } }
//123

Options

You can set default value through require('promixy').setDefault like that:

var _ = require('promixy').setDefault({
  methods: ['tap', 'map'],
  Promise: require('bluebird')
});

methods

If you use some module like bluebird that provide many method to Promise, you can choose what method can use on promixy.

Promise

You can define what Promise Library that promixy use.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.25latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.25
1.1.10
1.1.00
1.0.00

Package Sidebar

Install

npm i promixy

Weekly Downloads

5

Version

1.1.2

License

MIT

Last publish

Collaborators

  • ngtmuzi