Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including deferred-js with all npm packages installed. Try it out:

var deferredJs = require("deferred-js")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

deferred-js v1.0.2

Light (less than 1 kb gzipped) standalone implementation of promise/deferred that aims to be fully compatible with $.Deferred found in jQuery 1.5+.


deferred-js is a light (less than 1 kb gzipped) standalone implementation of promise/deferred that aims to be fully compatible with $.Deferred found in [jQuery 1.5+] (

What's implemented ?

  • Deferred.always
  • Deferred.done
  • Deferred.isRejected
  • Deferred.isResolved
  • Deferred.notify
  • Deferred.notifyWith
  • Deferred.progress
  • Deferred.promise
  • Deferred.reject
  • Deferred.rejectWith
  • Deferred.resolve
  • Deferred.resolveWith
  • Deferred.state
  • Deferred.then
  • Deferred.when

What's Missing ?

  • Deferred.pipe


Using nodejs

  • type in a terminal: npm install deferred-js
  • require deferred-js: var Deferred = require('deferred-js');

Using a browser

  • include the deferred script:
  • Deferred is available inside the global object


// Create a Deferred and return its Promise
function asyncEvent(){
    var dfd = new Deferred();
    }, Math.floor(Math.random()*1500));
    }, Math.floor(Math.random()*1500));
    return dfd.promise();

// Attach a done and fail handler for the asyncEvent
        console.log( status+', things are going well' );
        console.log( status+', you fail this time' );


This software is distributed under an MIT licence.

Copyright 2012 © Nicolas Ramz

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the Software.


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free