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

ts-deferred

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-deferred

Very simple implementation of Deferred for TypeScript

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14K
decreased by-3.48%
Maintainers
1
Weekly downloads
 
Created
Source

ts-deferred

Very simple implementation of Deferred for TypeScript.

Install

$ npm install --save ts-deferred

Usage

in TypeScript
import {Deferred} from "ts-deferred";

let d: Deferred<string> = new Deferred<string>();
let p: Promise<string> = d.promise;

p.then(text => console.log(text));

d.resolve("Hello World!!");
in JavaScript
let Deferred = require("ts-deferred").Deferred;

let d = new Deferred();
let p = d.promise;

p.then(function (text) {
  console.log(text);
});

d.resolve("Hello World!!");

API

promise: Promise<T>

The promise.

resolve(value?: T | PromiseLike<T>): void

Resolves the promise with the given value.

reject(reason?: any): void

Rejects the promise with the given reason.

Dependency

This library has no implementation of Promise<T>. If the target is es5 or less, it's depends to es6-promise or es6-shim.

How to build and test

  1. Clone this repository.
  2. Run npm install to install dependencies.
  3. Run npm run build or npm test.

License

MIT

Keywords

FAQs

Package last updated on 01 May 2017

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