Socket
Socket
Sign inDemoInstall

simply-deferred

Package Overview
Dependencies
0
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

43

deferred_test.js

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

// Generated by CoffeeScript 1.3.1
// Generated by CoffeeScript 1.6.3
(function() {

@@ -186,2 +186,17 @@ var assert, assertHasPromiseApi, assertIsPromise, deferred, expectedMethods, _,

});
it('should pipe with arrays intact', function(done) {
var def, filtered, finisher;
finisher = function(value) {
if (value.length === [1, 2, 3].length) {
return done();
}
};
def = new deferred.Deferred();
filtered = def.pipe(null, function(value) {
value.push(3);
return value;
});
def.reject([1, 2]);
return filtered.fail(finisher);
});
it('should pass through for null filters for done', function(done) {

@@ -199,3 +214,3 @@ var def, filtered, finisher;

});
return it('should pass through for null filters for fail', function(done) {
it('should pass through for null filters for fail', function(done) {
var def, filtered, finisher;

@@ -212,2 +227,22 @@ finisher = function(value) {

});
return it('should accept promises from filters and call them later with arguments', function(done) {
var def, filter;
def = deferred.Deferred();
filter = function(result) {
var def2;
assert.equal(result, 'r1');
def2 = deferred.Deferred();
setTimeout((function() {
return def2.resolve('r2');
}), 100);
return def2;
};
def.then(filter).done(function(result) {
assert.equal(result, 'r2');
if (result === 'r2') {
return done();
}
});
return def.resolve('r1');
});
});

@@ -232,5 +267,5 @@ describe('then', function() {

assertIsPromise(promise.always(callback));
assert("pending", promise.state());
assert.equal("pending", promise.state());
def.resolve();
return assert("resolved", promise.state());
return assert.equal("resolved", promise.state());
});

@@ -237,0 +272,0 @@ it('should create a promise out of a given object', function() {

34

deferred.js

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

// Generated by CoffeeScript 1.3.1
// Generated by CoffeeScript 1.6.3
(function() {

@@ -6,3 +6,3 @@ var Deferred, PENDING, REJECTED, RESOLVED, VERSION, after, execute, flatten, has, installInto, isArguments, wrap, _when,

VERSION = '2.0.0';
VERSION = '2.1.0';

@@ -71,2 +71,5 @@ PENDING = "pending";

var close, closingArguments, doneCallbacks, failCallbacks, state;
this.isPromise = function() {
return true;
};
state = PENDING;

@@ -106,15 +109,28 @@ doneCallbacks = [];

deferred = new Deferred();
filter = function(target, source, filter) {
filter = function(source, destination, filter) {
if (filter) {
return target(function() {
return source(filter.apply(null, flatten(arguments)));
return candidate[source](function() {
var args, filteredArgs;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
filteredArgs = filter.apply(null, args);
if (has(filteredArgs, 'isPromise') && filteredArgs.isPromise()) {
return filteredArgs[source](function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return destination.apply(null, args);
});
} else {
return destination(filteredArgs);
}
});
} else {
return target(function() {
return source.apply(null, flatten(arguments));
return candidate[source](function() {
var args;
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return destination.apply(null, args);
});
}
};
filter(candidate.done, deferred.resolve, doneFilter);
filter(candidate.fail, deferred.reject, failFilter);
filter('done', deferred.resolve, doneFilter);
filter('fail', deferred.reject, failFilter);
return deferred;

@@ -121,0 +137,0 @@ };

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

// Generated by CoffeeScript 1.3.1
(function(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n=[].slice;e="2.0.0",b="pending",d="resolved",c="rejected",i=function(a,b){return a!=null?a.hasOwnProperty(b):void 0},k=function(a){return i(a,"length")&&i(a,"callee")},h=function(a){return k(a)?h(Array.prototype.slice.call(a)):Array.isArray(a)?a.reduce(function(a,b){return Array.isArray(b)?a.concat(h(b)):(a.push(b),a)},[]):[a]},f=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}},l=function(a,b){return function(){var c;return c=[a].concat(Array.prototype.slice.call(arguments,0)),b.apply(this,c)}},g=function(a,b,c){var d,e,f,g,i;g=h(a),i=[];for(e=0,f=g.length;e<f;e++)d=g[e],i.push(d.call.apply(d,[c].concat(n.call(b))));return i},a=function(){var e,f,i,j,k;return k=b,i=[],j=[],f={},this.promise=function(e){var l,m;return e=e||{},e.state=function(){return k},m=function(a,c){return function(){return k===b&&c.push.apply(c,h(arguments)),a()&&g(arguments,f),e}},e.done=m(function(){return k===d},i),e.fail=m(function(){return k===c},j),e.always=function(){var a;return(a=e.done.apply(e,arguments)).fail.apply(a,arguments)},l=function(b,c){var d,f;return d=new a,f=function(a,b,c){return c?a(function(){return b(c.apply(null,h(arguments)))}):a(function(){return b.apply(null,h(arguments))})},f(e.done,d.resolve,b),f(e.fail,d.reject,c),d},e.pipe=l,e.then=l,e},this.promise(this),e=function(a,c,d){return function(){return k===b&&(k=a,f=arguments,g(c,f,d)),this}},this.resolve=e(d,i),this.reject=e(c,j),this.resolveWith=function(){var a,b;return b=arguments[0],a=2<=arguments.length?n.call(arguments,1):[],e(d,i,b).apply(null,a)},this.rejectWith=function(){var a,b;return b=arguments[0],a=2<=arguments.length?n.call(arguments,1):[],e(c,j,b).apply(null,a)},this},m=function(){var b,c,d,e,g,i,j;g=new a,c=h(arguments),c.length===1?c[0].done(function(){return g.resolve.apply(g,arguments)}):(e=[],d=f(c.length,function(){return g.resolve.apply(g,e)}),c.forEach(function(a,b){return a.done(function(){var a;return a=1<=arguments.length?n.call(arguments,0):[],e[b]=a,d()})}));for(i=0,j=c.length;i<j;i++)b=c[i],b.fail(g.reject);return g.promise()},j=function(b){return b.Deferred=function(){return new a},b.ajax=l(b.ajax,function(b,c){var d,e,f,g;return c==null&&(c={}),e=new a,d=function(a,b){return l(a,function(){var a,c;return c=arguments[0],a=2<=arguments.length?n.call(arguments,1):[],c&&c.apply(null,a),b.apply(null,a)})},c.success=d(c.success,e.resolve),c.error=d(c.error,e.reject),g=b(c),f=e.promise(),f.abort=function(){return g.abort()},f}),b.when=m},typeof exports!="undefined"?(exports.Deferred=function(){return new a},exports.when=m,exports.installInto=j):(this.Deferred=function(){return new a},this.Deferred.when=m,this.Deferred.installInto=j)}).call(this);
!function(){var n,r,e,t,u,a,l,i,o,s,c,f,p,g=[].slice;u="2.1.0",r="pending",t="resolved",e="rejected",o=function(n,r){return null!=n?n.hasOwnProperty(r):void 0},c=function(n){return o(n,"length")&&o(n,"callee")},i=function(n){return c(n)?i(Array.prototype.slice.call(n)):Array.isArray(n)?n.reduce(function(n,r){return Array.isArray(r)?n.concat(i(r)):(n.push(r),n)},[]):[n]},a=function(n,r){return 0>=n?r():function(){return--n<1?r.apply(this,arguments):void 0}},f=function(n,r){return function(){var e;return e=[n].concat(Array.prototype.slice.call(arguments,0)),r.apply(this,e)}},l=function(n,r,e){var t,u,a,l,o;for(l=i(n),o=[],u=0,a=l.length;a>u;u++)t=l[u],o.push(t.call.apply(t,[e].concat(g.call(r))));return o},n=function(){var u,a,s,c,f;return this.isPromise=function(){return!0},f=r,s=[],c=[],a={},this.promise=function(u){var p,h;return u=u||{},u.state=function(){return f},h=function(n,e){return function(){return f===r&&e.push.apply(e,i(arguments)),n()&&l(arguments,a),u}},u.done=h(function(){return f===t},s),u.fail=h(function(){return f===e},c),u.always=function(){var n;return(n=u.done.apply(u,arguments)).fail.apply(n,arguments)},p=function(r,e){var t,a;return t=new n,a=function(n,r,e){return e?u[n](function(){var t,u;return t=1<=arguments.length?g.call(arguments,0):[],u=e.apply(null,t),o(u,"isPromise")&&u.isPromise()?u[n](function(){var n;return n=1<=arguments.length?g.call(arguments,0):[],r.apply(null,n)}):r(u)}):u[n](function(){var n;return n=1<=arguments.length?g.call(arguments,0):[],r.apply(null,n)})},a("done",t.resolve,r),a("fail",t.reject,e),t},u.pipe=p,u.then=p,u},this.promise(this),u=function(n,e,t){return function(){return f===r&&(f=n,a=arguments,l(e,a,t)),this}},this.resolve=u(t,s),this.reject=u(e,c),this.resolveWith=function(){var n,r;return r=arguments[0],n=2<=arguments.length?g.call(arguments,1):[],u(t,s,r).apply(null,n)},this.rejectWith=function(){var n,r;return r=arguments[0],n=2<=arguments.length?g.call(arguments,1):[],u(e,c,r).apply(null,n)},this},p=function(){var r,e,t,u,l,o,s;for(l=new n,e=i(arguments),1===e.length?e[0].done(function(){return l.resolve.apply(l,arguments)}):(u=[],t=a(e.length,function(){return l.resolve.apply(l,u)}),e.forEach(function(n,r){return n.done(function(){var n;return n=1<=arguments.length?g.call(arguments,0):[],u[r]=n,t()})})),o=0,s=e.length;s>o;o++)r=e[o],r.fail(l.reject);return l.promise()},s=function(r){return r.Deferred=function(){return new n},r.ajax=f(r.ajax,function(r,e){var t,u,a,l;return null==e&&(e={}),u=new n,t=function(n,r){return f(n,function(){var n,e;return e=arguments[0],n=2<=arguments.length?g.call(arguments,1):[],e&&e.apply(null,n),r.apply(null,n)})},e.success=t(e.success,u.resolve),e.error=t(e.error,u.reject),l=r(e),a=u.promise(),a.abort=function(){return l.abort()},a}),r.when=p},"undefined"!=typeof exports?(exports.Deferred=function(){return new n},exports.when=p,exports.installInto=s):(this.Deferred=function(){return new n},this.Deferred.when=p,this.Deferred.installInto=s)}.call(this);

@@ -5,3 +5,3 @@ {

"description": "A deferred library for Node.js and the browser with a simplified jQuery compatible API",
"version": "2.0.0",
"version": "2.1.0",
"homepage": "http://sudhirj.github.com/simply-deferred/",

@@ -8,0 +8,0 @@ "repository": {

@@ -7,4 +7,2 @@ #Simply Deferred

If you're on a browser, simply include
https://raw.github.com/sudhirj/simply-deferred/master/deferred.min.js

@@ -45,1 +43,9 @@ ##Usage

* Wraps `$.ajax` to return a `promise`, which has only the following methods: `state()`, `done()`, `fail()` and `always()`. The arguments passed to the `done` and `fail` callbacks are the same ones passed to the `success` and `error` options.
###Collaborating
Please feel free to raise issues on github.com/sudhirj/simply-deferred/issues - both obvious bugs or incompatibilities with jQuery are welcome.
If you'd like contribute a fix or a feature, that would be even better. Please make sure all pull requests are accompanied by tests, though.
If you'd like to start work on a feature that is not part of the jQuery library, let's talk about it first - the goal here for this library to be a drop in replacement for jQuery, with the same docs and API.

Sorry, the diff of this file is not supported yet

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc