Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Oct 7, 2022. It is now read-only.

avoidwork/tiny-defer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tiny-defer

Tiny Deferred for Client or Server

build status

Example

var deferred = require('tiny-defer');

function something () {
  var defer = deferred();

  setTimeout(function () {
    defer.resolve(true);
  }, 1000);
  
  return defer.promise;
}

something().then(function (arg) {
  console.log(arg); // true;
});

API

promise

Promise to pass/return

reject()

Rejects the Promise

resolve()

Resolves the Promise

How to use tiny-defer

tiny-defer can be loaded as a CommonJS or AMD module, or with a script tag which would create window.deferred.

License

Copyright (c) 2015 Jason Mulligan Licensed under the BSD-3 license

About

Tiny Deferred for Client and Server

Resources

License

Stars

Watchers

Forks

Packages

No packages published