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

promise-wtf

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-wtf - npm Package Compare versions

Comparing version 1.2.0 to 1.2.2

dist/promise-wtf.js

13

dist/promise-wtf.min.js

@@ -1,11 +0,2 @@

/**
* promise-wtf
* v1.2.0
* built: Wed, 28 Sep 2016 09:20:26 GMT
* git: https://github.com/ndaidong/promise-wtf
* author: @ndaidong
* License: MIT
**/
;(function(g,f){if("undefined"!==typeof module&&module.exports)module.exports=f();else{var b=window||{};b.define&&b.define.amd?b.define([],f):b.exports?b.exports=f():b[g]=f()}})("Promise",function(){var g="undefined"!==typeof module&&module.exports?"node":"browser",f=function(a){return a&&"[object Function]"==={}.toString.call(a)},b=function(a){var c=0,d=null,k,l=this,m=function(h){if(0===c)return d=h,!1;var a=2===c?h.onResolved:h.onRejected;return a?h.resolve(a(k)):2===c?h.resolve(k):h.reject(k)},
e=function(a){c=1;k=a;d&&m(d)},g=function(a){a&&f(a.then)?a.then(g,e):(c=2,k=a,d&&m(d))};l.then=function(a,c){return new b(function(b,d){return m({onResolved:a,onRejected:c,resolve:b,reject:d})})};l["catch"]=function(a){if(a&&f(a))return l.then(null,a)};return a(g,e)};b.resolve=function(a){return new b(function(c){return c(a)})};b.reject=function(a){return new b(function(c,b){return b(a)})};b.all=function(a){var c=[],d=b.resolve(null);a.forEach(function(a){d=d.then(function(){return a}).then(function(a){c.push(a)})});
return d.then(function(){return c})};var e=("node"===g?global:window).Promise||b;e.prototype["finally"]=function(a){return this.then(function(b){return e.resolve(a()).then(function(){return b})},function(b){return e.resolve(a()).then(function(){throw b;})})};e.series=function(a){return new e(function(b,d){var c=a.length,e=function(f){a[f](function(a){return a?d(a):f<c-1?e(f+1):b()})};return e(0)})};return e});
// promise-wtf@1.2.2, by @ndaidong - built on Fri, 18 Nov 2016 08:26:17 GMT - published under MIT license
;var _createClass=function(){function defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}return function(Constructor,protoProps,staticProps){if(protoProps)defineProperties(Constructor.prototype,protoProps);if(staticProps)defineProperties(Constructor,staticProps);return Constructor}}();function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};(function(name,factory){if(typeof module!=="undefined"&&module.exports){module.exports=factory()}else{var root=window||{};if(root.define&&root.define.amd){root.define([],factory)}else if(root.exports){root.exports=factory()}else{root[name]=factory()}}}("Promise",function(){var ENV=typeof module!=="undefined"&&module.exports?"node":"browser";var PENDING=0;var REJECTED=1;var RESOLVED=2;var isFunction=function isFunction(v){return v&&{}.toString.call(v)==="[object Function]"};var P=function(){function P(fn){_classCallCheck(this,P);var _state=PENDING;var _deferred=null;var _value=void 0;var self=this;var handle=function handle(instance){if(_state===PENDING){_deferred=instance;return false}var cb=_state===RESOLVED?instance.onResolved:instance.onRejected;if(!cb){return _state===RESOLVED?instance.resolve(_value):instance.reject(_value)}return instance.resolve(cb(_value))};var reject=function reject(reason){_state=REJECTED;_value=reason;if(_deferred){handle(_deferred)}};var resolve=function resolve(instance){if(instance&&isFunction(instance.then)){instance.then(resolve,reject);return}_state=RESOLVED;_value=instance;if(_deferred){handle(_deferred)}};self.then=function(onResolved,onRejected){return new P(function(_resolve,_reject){return handle({onResolved:onResolved,onRejected:onRejected,resolve:_resolve,reject:_reject})})};self["catch"]=function(onRejected){return self.then(null,onRejected)};return fn(resolve,reject)}_createClass(P,null,[{key:"resolve",value:function resolve(value){return new P(function(resolve){return resolve(value)})}},{key:"reject",value:function reject(value){return new P(function(resolve,reject){return reject(value)})}},{key:"all",value:function all(promises){var results=[];var done=P.resolve(null);promises.forEach(function(promise){done=done.then(function(){return promise}).then(function(value){results.push(value)})});return done.then(function(){return results})}}]);return P}();var root=ENV==="node"?global:window;var $P=root.Promise||P;$P.prototype["finally"]=function(func){return this.then(function(value){return $P.resolve(func()).then(function(){return value})})};$P.series=function(tasks){return new $P(function(resolve,reject){var t=tasks.length;var exec=function exec(k){tasks[k](function(err){if(err){return reject(err)}if(k<t-1){return exec(k+1)}return resolve()})};return exec(0)})};return $P}));
{
"version": "1.2.0",
"version": "1.2.2",
"name": "promise-wtf",

@@ -21,7 +21,7 @@ "description": "Lightweight Promise implementation with the 'finally' method",

"pretest": "npm run lint && npm run snyk",
"test": "npm run tape",
"test": "npm run aplus && npm run tape",
"posttest": "npm run report",
"coveralls": "npm test && cat ./coverage/lcov.info | coveralls",
"aplus": "node ./test/aplus/index.js",
"build": "gccmin src dist"
"build": "gccmin"
},

@@ -40,2 +40,8 @@ "devDependencies": {

},
"gccmin": {
"source": "src",
"target": "dist",
"filename": "promise-wtf",
"globalVar": "Promise"
},
"keywords": [

@@ -46,12 +52,3 @@ "library",

],
"license": "MIT",
"maintainers": [
"ndaidong <ndaidong@gmail.com>"
],
"bugs": {
"url": "https://github.com/ndaidong/promise-wtf/issues"
},
"directories": {
"test": "test"
}
"license": "MIT"
}

@@ -5,5 +5,5 @@ # promise-wtf

[![NPM](https://badge.fury.io/js/promise-wtf.svg)](https://badge.fury.io/js/promise-wtf)
![Travis](https://travis-ci.org/ndaidong/promise-wtf.svg?branch=master)
[![Build Status](https://travis-ci.org/ndaidong/promise-wtf.svg?branch=master)](https://travis-ci.org/ndaidong/promise-wtf)
[![Coverage Status](https://coveralls.io/repos/github/ndaidong/promise-wtf/badge.svg?branch=master)](https://coveralls.io/github/ndaidong/promise-wtf?branch=master)
[![Dependency Status](https://www.versioneye.com/user/projects/57e8dfac79806f002f4ade1e/badge.svg?style=flat)](https://www.versioneye.com/user/projects/57e8dfac79806f002f4ade1e)
[![Dependency Status](https://gemnasium.com/badges/github.com/ndaidong/promise-wtf.svg)](https://gemnasium.com/github.com/ndaidong/promise-wtf)
[![Known Vulnerabilities](https://snyk.io/test/npm/promise-wtf/badge.svg)](https://snyk.io/test/npm/promise-wtf)

@@ -111,8 +111,5 @@

[Promise.min.js](https://cdn.rawgit.com/ndaidong/promise-wtf/master/dist/promise-wtf.min.js)
- [promise-wtf.js](https://cdn.rawgit.com/ndaidong/promise-wtf/master/dist/promise-wtf.js)
- [promise-wtf.min.js](https://cdn.rawgit.com/ndaidong/promise-wtf/master/dist/promise-wtf.min.js)
```
<script type="text/javascript" src="https://cdn.rawgit.com/ndaidong/promise-wtf/master/dist/promise-wtf.min.js"></script>
```
- This library also supports ES6 Module, AMD and UMD style.

@@ -119,0 +116,0 @@

@@ -7,164 +7,137 @@ /**

((name, factory) => {
if (typeof module !== 'undefined' && module.exports) {
module.exports = factory();
} else {
var root = window || {};
if (root.define && root.define.amd) {
root.define([], factory);
} else if (root.exports) {
root.exports = factory();
} else {
root[name] = factory();
}
}
})('Promise', () => {
const ENV = typeof module !== 'undefined' && module.exports ? 'node' : 'browser';
const ENV = typeof module !== 'undefined' && module.exports ? 'node' : 'browser';
const PENDING = 0;
const REJECTED = 1;
const RESOLVED = 2;
const PENDING = 0;
const REJECTED = 1;
const RESOLVED = 2;
var isFunction = (v) => {
return v && {}.toString.call(v) === '[object Function]';
};
var isFunction = (v) => {
return v && {}.toString.call(v) === '[object Function]';
};
class P {
var doNothing = () => {
return;
};
constructor(fn) {
class P {
let _state = PENDING;
let _deferred = null;
let _value;
constructor(fn) {
let self = this; // eslint-disable-line consistent-this
let _state = PENDING;
let _deferred = null;
let _value;
let handle = (instance) => {
let self = this; // eslint-disable-line consistent-this
if (_state === PENDING) {
_deferred = instance;
return false;
}
let handle = (instance) => {
let cb = _state === RESOLVED ? instance.onResolved : instance.onRejected;
if (_state === PENDING) {
_deferred = instance;
return false;
}
if (!cb) {
return _state === RESOLVED ? instance.resolve(_value) : instance.reject(_value);
}
let cb = _state === RESOLVED ? instance.onResolved : instance.onRejected;
return instance.resolve(cb(_value));
};
if (!cb) {
return _state === RESOLVED ? instance.resolve(_value) : instance.reject(_value);
}
let reject = (reason) => {
_state = REJECTED;
_value = reason;
return instance.resolve(cb(_value));
};
if (_deferred) {
handle(_deferred);
}
};
let reject = (reason) => {
_state = REJECTED;
_value = reason;
let resolve = (instance) => {
if (instance && isFunction(instance.then)) {
instance.then(resolve, reject);
return;
}
_state = RESOLVED;
_value = instance;
if (_deferred) {
handle(_deferred);
}
};
if (_deferred) {
handle(_deferred);
}
};
let resolve = (instance) => {
if (instance && isFunction(instance.then)) {
instance.then(resolve, reject);
return;
}
_state = RESOLVED;
_value = instance;
if (_deferred) {
handle(_deferred);
}
};
self.then = (onResolved, onRejected) => {
return new P((_resolve, _reject) => {
return handle({
onResolved,
onRejected,
resolve: _resolve,
reject: _reject
});
self.then = (onResolved, onRejected) => {
return new P((_resolve, _reject) => {
return handle({
onResolved,
onRejected,
resolve: _resolve,
reject: _reject
});
};
});
};
self['catch'] = (onRejected) => { // eslint-disable-line dot-notation
if (onRejected && isFunction(onRejected)) {
return self.then(null, onRejected);
}
return doNothing();
};
self['catch'] = (onRejected) => { // eslint-disable-line dot-notation
return self.then(null, onRejected);
};
return fn(resolve, reject);
}
return fn(resolve, reject);
}
static resolve(value) {
return new P((resolve) => {
return resolve(value);
});
}
static resolve(value) {
return new P((resolve) => {
return resolve(value);
});
}
static reject(value) {
return new P((resolve, reject) => {
return reject(value);
});
}
static reject(value) {
return new P((resolve, reject) => {
return reject(value);
});
}
static all(promises) {
static all(promises) {
let results = [];
let done = P.resolve(null);
let results = [];
let done = P.resolve(null);
promises.forEach((promise) => {
done = done.then(() => {
return promise;
}).then((value) => {
results.push(value);
});
promises.forEach((promise) => {
done = done.then(() => {
return promise;
}).then((value) => {
results.push(value);
});
return done.then(() => {
return results;
});
}
});
return done.then(() => {
return results;
});
}
}
var root = ENV === 'node' ? global : window;
var $P = root.Promise || P;
var root = ENV === 'node' ? global : window;
var $P = root.Promise || P;
$P.prototype['finally'] = function(func) { // eslint-disable-line
return this.then((value) => {
return $P.resolve(func()).then(() => {
return value;
});
}, (error) => {
return $P.resolve(func()).then(() => {
throw error;
});
$P.prototype['finally'] = function(func) { // eslint-disable-line
return this.then((value) => {
return $P.resolve(func()).then(() => {
return value;
});
};
});
};
$P.series = (tasks) => {
return new $P((resolve, reject) => {
let t = tasks.length;
let exec = (k) => {
tasks[k]((err) => {
if (err) {
return reject(err);
}
if (k < t - 1) {
return exec(k + 1);
}
return resolve();
});
};
return exec(0);
});
};
$P.series = (tasks) => {
return new $P((resolve, reject) => {
let t = tasks.length;
let exec = (k) => {
tasks[k]((err) => {
if (err) {
return reject(err);
}
if (k < t - 1) {
return exec(k + 1);
}
return resolve();
});
};
return exec(0);
});
};
return $P;
});
module.exports = $P;
/**
* Check built-file to ensure it has been regenated
* Check built-files to ensure they have been regenated correctly
* @ndaidong

@@ -10,6 +10,6 @@ */

var pkgFake = require('../../package.json');
var proFile = './dist/promise-wtf.min.js';
var proFile = './dist/promise-wtf.js';
var devFile = './dist/promise-wtf.min.js';
test('Testing minified result', (assert) => {
test('Validate production output', (assert) => {
assert.ok(fs.existsSync(proFile), 'Production file must be generated');

@@ -30,1 +30,18 @@

});
test('Validate development output', (assert) => {
assert.ok(fs.existsSync(devFile), 'Development file must be generated');
let s = fs.readFileSync(devFile, 'utf8');
let a = s.split('\n');
assert.ok(s.length > 0 && a.length > 1, 'Development file must be not empty');
let cmt = a[0];
let pack = `${pkgFake.name}@${pkgFake.version}`;
assert.ok(cmt.includes(pack), 'Package must be presented with name and version');
let author = `${pkgFake.author}`;
assert.ok(cmt.includes(author), 'Package author must be correct');
let license = `${pkgFake.license}`;
assert.ok(cmt.includes(license), 'Package license must be correct');
assert.end();
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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