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

promiz

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promiz - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "promiz",
"version": "1.0.0",
"version": "1.0.1",
"description": "A proper compact promise (promises/A+ spec compliant) library.",

@@ -5,0 +5,0 @@ "main": "promiz.js",

(function () {
global = this
var queueId = 1
var queue = {}
var isRunningTask = false
if (!global.setImmediate)
global.addEventListener('message', function (e) {
if (e.source == global){
if (isRunningTask)
nextTick(queue[e.data])
else {
isRunningTask = true
try {
queue[e.data]()
} catch (e) {}
delete queue[e.data]
isRunningTask = false
}
}
})
function nextTick(fn) {
if (global.setImmediate) setImmediate(fn)
// if inside of web worker
else if (global.importScripts) setTimeout(fn)
else global.postMessage(queueId++, '*')
}
Deferred.resolve = function (value) {

@@ -133,3 +162,3 @@ if (!(this._d == 1))

setTimeout(fire)
nextTick(fire)
}

@@ -146,3 +175,3 @@ return this

setTimeout(fire)
nextTick(fire)
}

@@ -266,4 +295,4 @@ return this

} else {
this['Promise'] = Deferred
global['Promise'] = global['Promise'] || Deferred
}
})()

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

!function(){function a(b){function c(a,b,c,d){if("object"!=typeof i&&"function"!=typeof i||"function"!=typeof a)d();else try{var e=0;a.call(i,function(a){e++||(i=a,b())},function(a){e++||(i=a,c())})}catch(f){i=f,c()}}function d(){var a;try{a=i&&i.then}catch(b){return i=b,h=2,d()}c(a,function(){h=1,d()},function(){h=2,d()},function(){try{1==h&&"function"==typeof e?i=e(i):2==h&&"function"==typeof f&&(i=f(i),h=1)}catch(b){return i=b,k()}i==g?(i=TypeError(),k()):c(a,function(){k(3)},k,function(){k(1==h&&3)})})}if("function"!=typeof b&&void 0!=b)throw TypeError();var e,f,g=this,h=0,i=0,j=[];g.promise=g,g.resolve=function(a){return e=this.fn,f=this.er,h||(i=a,h=1,setTimeout(d)),this},g.reject=function(a){return e=this.fn,f=this.er,h||(i=a,h=2,setTimeout(d)),this},g.then=function(b,c){var d=new a;return d.fn=b,d.er=c,3==h?d.resolve(i):4==h?d.reject(i):j.push(d),d},g["catch"]=function(a){return g.then(null,a)};var k=function(a){h=a||4,j.map(function(a){3==h&&a.resolve(i)||a.reject(i)})};try{"function"==typeof b&&b(g.resolve,g.reject)}catch(l){g.reject(l)}return g}a.resolve=function(b){if(1!=this._d)throw TypeError();return new a(function(a){a(b)})},a.reject=function(b){if(1!=this._d)throw TypeError();return new a(function(a,c){c(b)})},a.all=function(b){function c(a,e){if(e)return d.resolve(e);if(a)return d.reject(a);var f=b.reduce(function(a,b){return b&&b.then?a+1:a},0);0==f&&d.resolve(b),b.map(function(a,d){a&&a.then&&a.then(function(a){return b[d]=a,c(),a},c)})}if(1!=this._d)throw TypeError();if(!(b instanceof Array))return a.reject(TypeError());var d=new a;return c(),d},a.race=function(b){function c(a,e){if(e)return d.resolve(e);if(a)return d.reject(a);var f=b.reduce(function(a,b){return b&&b.then?a+1:a},0);0==f&&d.resolve(b),b.map(function(a){a&&a.then&&a.then(function(a){c(null,a)},c)})}if(1!=this._d)throw TypeError();if(!(b instanceof Array))return a.reject(TypeError());if(0==b.length)return new a;var d=new a;return c(),d},a._d=1,"undefined"!=typeof module?module.exports=a:this.Promise=a}();
!function(){function a(a){global.setImmediate?setImmediate(a):global.importScripts?setTimeout(a):global.postMessage(c++,"*")}function b(c){function d(a,b,c,d){if("object"!=typeof j&&"function"!=typeof j||"function"!=typeof a)d();else try{var e=0;a.call(j,function(a){e++||(j=a,b())},function(a){e++||(j=a,c())})}catch(f){j=f,c()}}function e(){var a;try{a=j&&j.then}catch(b){return j=b,i=2,e()}d(a,function(){i=1,e()},function(){i=2,e()},function(){try{1==i&&"function"==typeof f?j=f(j):2==i&&"function"==typeof g&&(j=g(j),i=1)}catch(b){return j=b,l()}j==h?(j=TypeError(),l()):d(a,function(){l(3)},l,function(){l(1==i&&3)})})}if("function"!=typeof c&&void 0!=c)throw TypeError();var f,g,h=this,i=0,j=0,k=[];h.promise=h,h.resolve=function(b){return f=this.fn,g=this.er,i||(j=b,i=1,a(e)),this},h.reject=function(b){return f=this.fn,g=this.er,i||(j=b,i=2,a(e)),this},h.then=function(a,c){var d=new b;return d.fn=a,d.er=c,3==i?d.resolve(j):4==i?d.reject(j):k.push(d),d},h["catch"]=function(a){return h.then(null,a)};var l=function(a){i=a||4,k.map(function(a){3==i&&a.resolve(j)||a.reject(j)})};try{"function"==typeof c&&c(h.resolve,h.reject)}catch(m){h.reject(m)}return h}global=this;var c=1,d={},e=!1;global.setImmediate||global.addEventListener("message",function(b){if(b.source==global)if(e)a(d[b.data]);else{e=!0;try{d[b.data]()}catch(b){}delete d[b.data],e=!1}}),b.resolve=function(a){if(1!=this._d)throw TypeError();return new b(function(b){b(a)})},b.reject=function(a){if(1!=this._d)throw TypeError();return new b(function(b,c){c(a)})},b.all=function(a){function c(b,e){if(e)return d.resolve(e);if(b)return d.reject(b);var f=a.reduce(function(a,b){return b&&b.then?a+1:a},0);0==f&&d.resolve(a),a.map(function(b,d){b&&b.then&&b.then(function(b){return a[d]=b,c(),b},c)})}if(1!=this._d)throw TypeError();if(!(a instanceof Array))return b.reject(TypeError());var d=new b;return c(),d},b.race=function(a){function c(b,e){if(e)return d.resolve(e);if(b)return d.reject(b);var f=a.reduce(function(a,b){return b&&b.then?a+1:a},0);0==f&&d.resolve(a),a.map(function(a){a&&a.then&&a.then(function(a){c(null,a)},c)})}if(1!=this._d)throw TypeError();if(!(a instanceof Array))return b.reject(TypeError());if(0==a.length)return new b;var d=new b;return c(),d},b._d=1,"undefined"!=typeof module?module.exports=b:global.Promise=global.Promise||b}();

@@ -7,3 +7,3 @@ ![Promiz.js](https://raw.github.com/Zolmeister/promiz/master/imgs/logo.png)

</a>
A polyfill for ES6-style Promises in 402 bytes (gzip) (v0.3 [Blog Post](http://www.zolmeister.com/2014/01/promiz-micro-promises-in-228-bytes.html)) ~~([How it was built](http://www.zolmeister.com/2013/07/promizjs.html))~~
A polyfill for ES6-style Promises in 493 bytes (gzip) (v0.3 [Blog Post](http://www.zolmeister.com/2014/01/promiz-micro-promises-in-228-bytes.html)) ~~([How it was built](http://www.zolmeister.com/2013/07/promizjs.html))~~
![build-status](https://travis-ci.org/Zolmeister/promiz.png?branch=master)

@@ -22,3 +22,3 @@ ## Install

```
Promiz - **402 bytes** (min + gzip) - as reported by uglify.js
Promiz - **493 bytes** (min + gzip) - as reported by uglify.js
## Promiz

@@ -25,0 +25,0 @@ [HTML5rocks tutorial](http://www.html5rocks.com/en/tutorials/es6/promises/)

@@ -323,2 +323,28 @@ var Promise = require('./../promiz')

})
describe('performance', function () {
it('completes faster than setTimeout', function (done) {
resolver = null
thenCalled = false
var p = new Promise(function (resolve) {
resolver = resolve
})
p.then(function () {
thenCalled = true
})
start = Date.now()
resolver('resolved')
setTimeout(function () {
delta = Date.now() - start
expect(delta === 0 || delta === 0)
expect(thenCalled).to.be(true)
done()
})
})
})
})
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