New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

promise-ts

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-ts

TypeScript promises for Node.js.

  • 0.2.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

#promise-ts

Build Status Dependency Status NPM version Views

NPM

Promises for Node.js, written in TypeScript and distributed in JavaScript, along with a TypeScript definition file at the root (promise.d.ts). These promise classes and functions "mostly" behave like jQuery promises, so you can refer to jQuery documentation for more detailed information.

The following classes and function are made available to you:

  1. Deferred object (jQuery doc)
  2. Promise object (jQuery doc)
  3. when function (jQuery doc)

The only known differences between the jQuery counterparts are in cases like jQuery's deferred.done, where the documentation states, "The deferred.done() method accepts one or more arguments, all of which can be either a single function or an array of functions." In this library's case, it's just a TypeScript (...callbacks: Function[]) method signature. Contributions are welcome to fix this, but I didn't have the need to go down that road myself.

Example Usage

TypeScript

///<reference path='node_modules/promise-ts/promise-ts.d.ts'/>
import promise = require('promise-ts');
var Deferred = promise.Deferred;
var when = promise.when; // not used in this example, but handy.

function doSomethingAsync(): promise.Promise {
    var d = new Deferred();
    setTimeout(() => {
        // time consuming operations
        d.resolve('foo');
    });
    return d.promise;
}

doSomethingAsync.done(result => {
    // result === 'foo';
});

JavaScript

var promise = require('promise-ts');
var Deferred = promise.Deferred;
var when = promise.when; // not used in this example, but handy.

function doSomethingAsync() {
    var d = new Deferred();
    setTimeout(function() {
        // time consuming operations
        d.resolve('foo');
    });
    return d.promise;
}

doSomethingAsync.done(function(result) {
    // result === 'foo';
});

See the specs for more examples. The library and specs have both been written to satisfy the jQuery usages.

License

MIT © Jed Mao

Bitdeli Badge

Keywords

FAQs

Package last updated on 31 Jan 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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