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

zousan

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zousan - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

2

bower.json
{
"name": "zousan",
"version": "2.1.2",
"version": "2.2.0",
"homepage": "https://github.com/bluejava/zousan",

@@ -5,0 +5,0 @@ "authors":

{
"name": "zousan",
"version": "2.1.2",
"version": "2.2.0",
"description": "A Lightning Fast, Yet Very Small Promise A+ Compliant Implementation",

@@ -5,0 +5,0 @@ "main": "zousan-min.js",

@@ -118,5 +118,5 @@ <a href="http://promises-aplus.github.com/promises-spec">

###timeout(ms)
###timeout(ms[,msg])
New for version 1.2, this method returns a new promise based on the original that times out (rejects with ```Error("Timeout")```) if the original promise does not resolve or reject before the time specified (in milliseconds).
This method returns a new promise based on the original that times out (rejects with `Error("Timeout")` or if specified `Error(msg)`) if the original promise does not resolve or reject before the time specified (in milliseconds).

@@ -123,0 +123,0 @@ ```javascript

// zousan - A Lightning Fast, Yet Very Small Promise A+ Compliant Implementation
// https://github.com/bluejava/zousan
// Version 2.1.2
// Version 2.2.0
// License: MIT

@@ -197,4 +198,5 @@ /* jshint asi: true, browser: true */

// Note: this has no effect on the original promise - which may still resolve/reject at a later time.
"timeout" : function(ms)
"timeout" : function(ms,timeoutMsg)
{
timeoutMsg = timeoutMsg || "Timeout"
var me = this;

@@ -204,3 +206,3 @@ return new Zousan(function(resolve,reject) {

setTimeout(function() {
reject(Error("Timeout")); // This will fail silently if promise already resolved or rejected
reject(Error(timeoutMsg)); // This will fail silently if promise already resolved or rejected
}, ms);

@@ -207,0 +209,0 @@

@@ -93,4 +93,9 @@ /* jshint asi: true */

}).catch(function(reason) {
assert.equal(reason.name,"Error");
assert.equal(reason.message,"Timeout");
try
{
assert.equal(reason.name,"Error");
assert.equal(reason.message,"Timeout");
}
catch(err) { return done(err) }
done();

@@ -105,2 +110,27 @@ });

it("allows for custom timeout messages", function(done) {
var p1 = new Zousan(); // Create a promise
var customTimeoutMsg = "Test Timeout Message 100";
var p2 = p1.timeout(100,customTimeoutMsg); // Create another promise against p1 that times out in 100ms
p2.then(function(value) {
done(Error("Should not resolve in this case"));
}).catch(function(reason) {
try
{
assert.equal(reason.name,"Error");
assert.equal(reason.message,customTimeoutMsg);
}
catch(err) { return done(err) }
done();
});
// Resolve the original promise in 200ms (enough time to allow p2 to time out)
setTimeout(function() {
p1.resolve(5);
}, 200);
});
});

@@ -107,0 +137,0 @@

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

!function(t){"use strict";function e(t){if(t){var e=this;t(function(t){e.resolve(t)},function(t){e.reject(t)})}}function n(t,e){if("function"==typeof t.y)try{var n=t.y.call(i,e);t.p.resolve(n)}catch(o){t.p.reject(o)}else t.p.resolve(e)}function o(t,e){if("function"==typeof t.n)try{var n=t.n.call(i,e);t.p.resolve(n)}catch(o){t.p.reject(o)}else t.p.reject(e)}var r,i,c="fulfilled",u="rejected",s="undefined",f=function(){function t(){for(;e.length-n;)e[n](),n++,n>1024&&(e.splice(0,n),n=0)}var e=[],n=0,o=function(){if(typeof MutationObserver!==s){var e=document.createElement("div"),n=new MutationObserver(t);return n.observe(e,{attributes:!0}),function(){e.setAttribute("a",0)}}return typeof setImmediate!==s?function(){setImmediate(t)}:function(){setTimeout(t,0)}}();return function(t){e.push(t),e.length-n==1&&o()}}();e.prototype={resolve:function(t){if(this.state===r){if(t===this)return this.reject(new TypeError("Attempt to resolve promise with self"));var e=this;if(t&&("function"==typeof t||"object"==typeof t))try{var o=!0,i=t.then;if("function"==typeof i)return void i.call(t,function(t){o&&(o=!1,e.resolve(t))},function(t){o&&(o=!1,e.reject(t))})}catch(u){return void(o&&this.reject(u))}this.state=c,this.v=t,e.c&&f(function(){for(var o=0,r=e.c.length;r>o;o++)n(e.c[o],t)})}},reject:function(t){if(this.state===r){this.state=u,this.v=t;var n=this.c;n?f(function(){for(var e=0,r=n.length;r>e;e++)o(n[e],t)}):e.suppressUncaughtRejectionError||console.log("You upset Zousan. Please catch rejections: ",t,t.stack)}},then:function(t,i){var u=new e,s={y:t,n:i,p:u};if(this.state===r)this.c?this.c.push(s):this.c=[s];else{var l=this.state,a=this.v;f(function(){l===c?n(s,a):o(s,a)})}return u},"catch":function(t){return this.then(null,t)},"finally":function(t){return this.then(t,t)},timeout:function(t){var n=this;return new e(function(e,o){setTimeout(function(){o(Error("Timeout"))},t),n.then(function(t){e(t)},function(t){o(t)})})}},e.resolve=function(t){var n=new e;return n.resolve(t),n},e.reject=function(t){var n=new e;return n.reject(t),n},e.all=function(t){function n(n,c){"function"!=typeof n.then&&(n=e.resolve(n)),n.then(function(e){o[c]=e,r++,r==t.length&&i.resolve(o)},function(t){i.reject(t)})}for(var o=[],r=0,i=new e,c=0;c<t.length;c++)n(t[c],c);return t.length||i.resolve(o),i},typeof module!=s&&module.exports&&(module.exports=e),t.Zousan=e,e.soon=f}("undefined"!=typeof global?global:this);
!function(t){"use strict";function e(t){if(t){var e=this;t(function(t){e.resolve(t)},function(t){e.reject(t)})}}function n(t,e){if("function"==typeof t.y)try{var n=t.y.call(i,e);t.p.resolve(n)}catch(o){t.p.reject(o)}else t.p.resolve(e)}function o(t,e){if("function"==typeof t.n)try{var n=t.n.call(i,e);t.p.resolve(n)}catch(o){t.p.reject(o)}else t.p.reject(e)}var r,i,c="fulfilled",u="rejected",s="undefined",f=function(){function t(){for(;e.length-n;)e[n](),n++,n>1024&&(e.splice(0,n),n=0)}var e=[],n=0,o=function(){if(typeof MutationObserver!==s){var e=document.createElement("div"),n=new MutationObserver(t);return n.observe(e,{attributes:!0}),function(){e.setAttribute("a",0)}}return typeof setImmediate!==s?function(){setImmediate(t)}:function(){setTimeout(t,0)}}();return function(t){e.push(t),e.length-n==1&&o()}}();e.prototype={resolve:function(t){if(this.state===r){if(t===this)return this.reject(new TypeError("Attempt to resolve promise with self"));var e=this;if(t&&("function"==typeof t||"object"==typeof t))try{var o=!0,i=t.then;if("function"==typeof i)return void i.call(t,function(t){o&&(o=!1,e.resolve(t))},function(t){o&&(o=!1,e.reject(t))})}catch(u){return void(o&&this.reject(u))}this.state=c,this.v=t,e.c&&f(function(){for(var o=0,r=e.c.length;r>o;o++)n(e.c[o],t)})}},reject:function(t){if(this.state===r){this.state=u,this.v=t;var n=this.c;n?f(function(){for(var e=0,r=n.length;r>e;e++)o(n[e],t)}):e.suppressUncaughtRejectionError||console.log("You upset Zousan. Please catch rejections: ",t,t.stack)}},then:function(t,i){var u=new e,s={y:t,n:i,p:u};if(this.state===r)this.c?this.c.push(s):this.c=[s];else{var l=this.state,a=this.v;f(function(){l===c?n(s,a):o(s,a)})}return u},"catch":function(t){return this.then(null,t)},"finally":function(t){return this.then(t,t)},timeout:function(t,n){n=n||"Timeout";var o=this;return new e(function(e,r){setTimeout(function(){r(Error(n))},t),o.then(function(t){e(t)},function(t){r(t)})})}},e.resolve=function(t){var n=new e;return n.resolve(t),n},e.reject=function(t){var n=new e;return n.reject(t),n},e.all=function(t){function n(n,c){"function"!=typeof n.then&&(n=e.resolve(n)),n.then(function(e){o[c]=e,r++,r==t.length&&i.resolve(o)},function(t){i.reject(t)})}for(var o=[],r=0,i=new e,c=0;c<t.length;c++)n(t[c],c);return t.length||i.resolve(o),i},typeof module!=s&&module.exports&&(module.exports=e),t.Zousan=e,e.soon=f}("undefined"!=typeof global?global:this);
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