promise-toolbox
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -54,3 +54,3 @@ 'use strict';Object.defineProperty(exports,"__esModule",{value:true});exports.TimeoutError=exports.finally=exports.fromCallback=exports.forOwn=exports.forIterable=exports.forIn=exports.forEach=exports.forArray=exports.makeAsyncIterator=exports.defer=exports.cancellable=exports.nodeify=exports.isPromise=undefined;exports.all=all;exports.asCallback=asCallback;exports.delay=delay;exports.join=join;exports.lastly=lastly;exports.promisify=promisify;exports.promisifyAll=promisifyAll;exports.reflect=reflect;exports.settle=settle;exports.some=some;exports.timeout=timeout;var _makeError=require('make-error');function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called");}return call&&(typeof call==="object"||typeof call==="function")?call:self;}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass);}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass;} // =================================================================== | ||
function promisify(thisArg){var fn=this;return _setFunctionNameAndLength(function(){var _this=this;var _arguments=arguments;var length=_arguments.length;var args=new Array(length+1);for(var i=0;i<length;++i){args[i]=arguments[i];}return new Promise(function(resolve,reject){args[length]=function(error,result){return error?reject(error):resolve(result);};fn.apply(thisArg||_this,args);});},fn.name,fn.length&&fn.length-1);} // Usage: obj::promisifyAll([ mapper ]) | ||
var DEFAULT_PALL_MAPPER=function DEFAULT_PALL_MAPPER(name,fn){return !(_endsWith(name,'Sync')||_endsWith(name,'Async'))&&name+'Async';};function promisifyAll(){var _this2=this;var mapper=arguments.length<=0||arguments[0]===undefined?DEFAULT_PALL_MAPPER:arguments[0];var result={};_forIn(this,function(value,name){var newName=undefined;if(typeof value==='function'&&(newName=mapper(name,value,_this2))){result[newName]=promisify.call(value);}});return result;} // ------------------------------------------------------------------- | ||
var DEFAULT_PALL_MAPPER=function DEFAULT_PALL_MAPPER(name,fn){return !(_endsWith(name,'Sync')||_endsWith(name,'Async'))&&name+'Async';};function promisifyAll(){var _this2=this;var mapper=arguments.length<=0||arguments[0]===undefined?DEFAULT_PALL_MAPPER:arguments[0];var result={};_forIn(this,function(value,name){var newName=undefined;if(typeof value==='function'&&(newName=mapper(name,value,_this2))){result[newName]=promisify.call(value,_this2);}});return result;} // ------------------------------------------------------------------- | ||
var FN_FALSE=function FN_FALSE(){return false;};var FN_TRUE=function FN_TRUE(){return true;};var _reflectResolution=function(__proto__){return function(_value){return {__proto__:__proto__,value:function value(){return _value;}};};}({isFulfilled:FN_TRUE,isPending:FN_FALSE,isRejected:FN_FALSE,isResolved:FN_TRUE,reason:function reason(){throw new Error('no reason, the promise has resolved');}});var _reflectRejection=function(__proto__){return function(_reason){return {__proto__:__proto__,reason:function reason(){return _reason;}};};}({isFulfilled:FN_FALSE,isPending:FN_FALSE,isRejected:FN_TRUE,isResolved:FN_FALSE,value:function value(){throw new Error('no value, the promise has rejected');}}); // Returns a promise that is always successful when this promise is | ||
@@ -57,0 +57,0 @@ // settled. Its fulfillment value is an object that implements the |
{ | ||
"name": "promise-toolbox", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "description": "Essential utils for promises", |
@@ -170,16 +170,20 @@ # promise-toolbox [![Build Status](https://travis-ci.org/julien-f/js-promise-toolbox.png?branch=master)](https://travis-ci.org/julien-f/js-promise-toolbox) | ||
console.log([ | ||
[ | ||
Promise.resolve('foo'), | ||
Promise.resolve('bar') | ||
]::all()) | ||
// → ['foo', 'bar'] | ||
]::all().then(value => { | ||
console.log(value) | ||
// → ['foo', 'bar'] | ||
}) | ||
console.log({ | ||
{ | ||
foo: Promise.resolve('foo'), | ||
bar: Promise.resolve('bar') | ||
}::all()) | ||
// → { | ||
// foo: 'foo', | ||
// bar: 'bar' | ||
// } | ||
}::all().then(value => { | ||
console.log(value) | ||
// → { | ||
// foo: 'foo', | ||
// bar: 'bar' | ||
// } | ||
}) | ||
``` | ||
@@ -186,0 +190,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57503
362