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

ya-promise

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ya-promise - npm Package Compare versions

Comparing version 0.10.0 to 0.11.0

2

package.json
{
"name" : "ya-promise"
, "version" : "0.10.0"
, "version" : "0.11.0"
, "description" : "Yet Another promise/A+ library"

@@ -5,0 +5,0 @@ , "keywords" : ["defer", "deferred", "promise", "promise/A", "promise/A+"

@@ -80,2 +80,3 @@ # Yet Another Promise/A+ Library

### Create a Deferred & Promise
Q-alike: [`Q.defer()`][Qdefer]

@@ -121,2 +122,3 @@ ```javascript

### Reject a Deferred
Q-alike: [`Q.reject()`][Qreject]

@@ -134,2 +136,4 @@ ```javascript

### Convert a value or a foreign Promise ([thenable][terminology]) to a Y Promise
Q-alike: [`Q()`][Qfunc]
Q-alike: [`Q.when()`][Qwhen]

@@ -151,2 +155,3 @@ ```javascript

### Create a Promise from an Array of Promises
Q-alike: [`Q.all()`][Qall]

@@ -190,2 +195,3 @@ ```javascript

### Create a Fulfilled or Rejected Promise
Q-alike: [`Q.reject()`][Qreject]

@@ -205,2 +211,3 @@ ```javascript

### Detect if an object ISA `ya-promise` Deferred or Promise.
Q-alike: [`Q.isPromise()`][Qispromise]

@@ -215,2 +222,4 @@ ```javascript

### Convert a **node-style** async function to a **promise-style** async function.
Q-alike: [`Q.denodeify`][Qdenodeify]
Q-alike: [`Q.nfbind`][Qdenodeify]

@@ -220,2 +229,3 @@ ```javascript

promiseFn = Y.nfbind(nodeFn)
promiseFn = Y.denodeify(nodeFn)
```

@@ -552,2 +562,9 @@ A **node-style** async function looks like this

[tldr]: http://www.urbandictionary.com/define.php?term=tl%3Bdr
"to long; don't read"
"to long; don't read"
[Qfunc]: https://github.com/kriskowal/q/wiki/API-Reference#qvalue
[Qdefer]: https://github.com/kriskowal/q/wiki/API-Reference#qdefer
[Qreject]: https://github.com/kriskowal/q/wiki/API-Reference#qrejectreason
[Qwhen]: https://github.com/kriskowal/q#the-middle
[Qall]: https://github.com/kriskowal/q/wiki/API-Reference#promiseall
[Qispromise]: https://github.com/kriskowal/q/wiki/API-Reference#qispromisevalue
[Qdenodeify]: https://github.com/kriskowal/q/wiki/API-Reference#qdenodeifynodefunc-args

@@ -86,5 +86,9 @@

Y.delay = function(ms){
return Y.resolved().delay(ms)
}
Y.promisify = promisify
Y.nfbind = promisify
Y.denodeify = promisify

@@ -180,2 +184,26 @@ Y.isPromise = function(p){ return p instanceof Promise }

Promise.prototype.timeout = function(ms){
var d = Y.defer()
, toid = setTimeout(function(){
//d.reject(new Error("Timed out after " + ms + " ms"))
d.reject("Timed out after " + ms + " ms")
}, ms)
if (typeof toid.unref === 'function') toid.unref()
this.then( function(v){ clearTimeout(toid); d.resolve(v) }
, function(r){ clearTimeout(toid); d.reject(r) } )
return d.promise
}
Promise.prototype.delay = function(ms){
var self = this
, d = Y.defer()
setTimeout(function(){ d.resolve(self) }, ms)
return d.promise
}
function createFulfilled(promise, value, spread) {

@@ -182,0 +210,0 @@ spread = spread || false

@@ -1,1 +0,1 @@

(function(e){if(typeof bootstrap==="function"){bootstrap("promise",e)}else if(typeof exports==="object"){module.exports=e()}else if(typeof define==="function"&&define.amd){define(e)}else if(typeof ses!=="undefined"){if(!ses.ok()){return}else{ses.makeY=e}}else{Y=e()}})(function(){"use strict";function e(n){return e.when(n)}e.defer=function(){return new i};e.deferred=e.defer;e.resolved=function(e){var n=new i;n.resolve(e);return n.promise};e.rejected=function(e){var n=new i;n.reject(e);return n.promise};e.when=function(e){if(n(e))return e;var r=new i;if(e&&typeof e.then==="function")e.then(function(e){r.resolve(e)},function(e){r.reject(e)});else r.resolve(e);return r.promise};e.all=function(n){var r=0,t=e.defer(),i=[];n.forEach(function(n,f){r+=1;e.when(n).then(function(e){r-=1;i[f]=e;if(r===0)t.resolve(i)},function(e){t.reject(e)})});return t.promise};e.promisify=l;e.nfbind=l;e.isPromise=function(e){return e instanceof f};e.isDeferred=function(e){return e instanceof i};var n=e.isPromise,r=e.isDeferred;var t;Object.defineProperty(e,"nextTick",{get:function(){return t},set:function(e){t=e;return e},configurable:true,enumerable:true});if(typeof setImmediate==="function"){if(typeof window!=="undefined")e.nextTick=setImmediate.bind(window);else e.nextTick=setImmediate}else if(typeof process!=="undefined"&&process.nextTick)e.nextTick=process.nextTick;else e.nextTick=function(e){setTimeout(e,0)};function i(){var e=[],n=new f(t,l),r={promise:n,resolve:d,reject:a};function t(n,r){var t=new i;e.push({deferred:t,fulfilled:n,rejected:r,spread:false});return t.promise}function l(n,r){var t=new i;e.push({deferred:t,fulfilled:n,rejected:r,spread:true});return t.promise}function d(t){for(var i=0;i<e.length;i++){if(typeof e[i].fulfilled!=="function")e[i].deferred.resolve(t);else c(e[i].fulfilled,t,e[i].deferred,e[i].spread)}r.reject=r.resolve=u;n.then=o(n,t,false);n.spread=o(n,t,true)}function a(t){for(var i=0;i<e.length;i++){if(typeof e[i].rejected!=="function")e[i].deferred.reject(t);else c(e[i].rejected,t,e[i].deferred,false)}r.reject=r.resolve=u;n.then=s(n,t);n.spread=s(n,t)}return r}function f(e,n){this.then=e;this.spread=n}function o(e,n,r){r=r||false;return function t(t,f){var o;if(typeof t!=="function")return e;c(t,n,o=new i,r);return o.promise}}function s(e,n){return function r(r,t){var f;if(typeof t!=="function")return e;c(t,n,f=new i,false);return f.promise}}function u(){}function c(e,n,r,i){t(function(){var t;try{if(i&&Array.isArray(n))t=e.apply(void 0,n);else t=e(n);if(t&&typeof t.then=="function")t.then(function(e){r.resolve(e)},function(e){r.reject(e)});else r.resolve(t)}catch(f){r.reject(f)}})}function l(n,r){return function(){var t=Array.prototype.slice.call(arguments),i=e.defer();t.push(function(e){if(e){i.reject(e);return}if(arguments.length>2)i.resolve(Array.prototype.slice.call(arguments,1));else i.resolve(arguments[1])});n.apply(r,t);return i.promise}}return e});
(function(e){if(typeof bootstrap==="function"){bootstrap("promise",e)}else if(typeof exports==="object"){module.exports=e()}else if(typeof define==="function"&&define.amd){define(e)}else if(typeof ses!=="undefined"){if(!ses.ok()){return}else{ses.makeY=e}}else{Y=e()}})(function(){"use strict";function e(n){return e.when(n)}e.defer=function(){return new i};e.deferred=e.defer;e.resolved=function(e){var n=new i;n.resolve(e);return n.promise};e.rejected=function(e){var n=new i;n.reject(e);return n.promise};e.when=function(e){if(n(e))return e;var r=new i;if(e&&typeof e.then==="function")e.then(function(e){r.resolve(e)},function(e){r.reject(e)});else r.resolve(e);return r.promise};e.all=function(n){var r=0,t=e.defer(),i=[];n.forEach(function(n,o){r+=1;e.when(n).then(function(e){r-=1;i[o]=e;if(r===0)t.resolve(i)},function(e){t.reject(e)})});return t.promise};e.delay=function(n){return e.resolved().delay(n)};e.promisify=l;e.nfbind=l;e.denodeify=l;e.isPromise=function(e){return e instanceof o};e.isDeferred=function(e){return e instanceof i};var n=e.isPromise,r=e.isDeferred;var t;Object.defineProperty(e,"nextTick",{get:function(){return t},set:function(e){t=e;return e},configurable:true,enumerable:true});if(typeof setImmediate==="function"){if(typeof window!=="undefined")e.nextTick=setImmediate.bind(window);else e.nextTick=setImmediate}else if(typeof process!=="undefined"&&process.nextTick)e.nextTick=process.nextTick;else e.nextTick=function(e){setTimeout(e,0)};function i(){var e=[],n=new o(t,l),r={promise:n,resolve:d,reject:a};function t(n,r){var t=new i;e.push({deferred:t,fulfilled:n,rejected:r,spread:false});return t.promise}function l(n,r){var t=new i;e.push({deferred:t,fulfilled:n,rejected:r,spread:true});return t.promise}function d(t){for(var i=0;i<e.length;i++){if(typeof e[i].fulfilled!=="function")e[i].deferred.resolve(t);else c(e[i].fulfilled,t,e[i].deferred,e[i].spread)}r.reject=r.resolve=s;n.then=f(n,t,false);n.spread=f(n,t,true)}function a(t){for(var i=0;i<e.length;i++){if(typeof e[i].rejected!=="function")e[i].deferred.reject(t);else c(e[i].rejected,t,e[i].deferred,false)}r.reject=r.resolve=s;n.then=u(n,t);n.spread=u(n,t)}return r}function o(e,n){this.then=e;this.spread=n}o.prototype.timeout=function(n){var r=e.defer(),t=setTimeout(function(){r.reject("Timed out after "+n+" ms")},n);if(typeof t.unref==="function")t.unref();this.then(function(e){clearTimeout(t);r.resolve(e)},function(e){clearTimeout(t);r.reject(e)});return r.promise};o.prototype.delay=function(n){var r=this,t=e.defer();setTimeout(function(){t.resolve(r)},n);return t.promise};function f(e,n,r){r=r||false;return function t(t,o){var f;if(typeof t!=="function")return e;c(t,n,f=new i,r);return f.promise}}function u(e,n){return function r(r,t){var o;if(typeof t!=="function")return e;c(t,n,o=new i,false);return o.promise}}function s(){}function c(e,n,r,i){t(function(){var t;try{if(i&&Array.isArray(n))t=e.apply(void 0,n);else t=e(n);if(t&&typeof t.then=="function")t.then(function(e){r.resolve(e)},function(e){r.reject(e)});else r.resolve(t)}catch(o){r.reject(o)}})}function l(n,r){return function(){var t=Array.prototype.slice.call(arguments),i=e.defer();t.push(function(e){if(e){i.reject(e);return}if(arguments.length>2)i.resolve(Array.prototype.slice.call(arguments,1));else i.resolve(arguments[1])});n.apply(r,t);return i.promise}}return e});
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