Socket
Book a DemoInstallSign in
Socket

promiseful

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

promiseful

Useful patterns with Promise functions

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

promiseful

Useful patterns with Promise functions

NPM version Build Status Known Vulnerabilities

Installation

$ npm install promiseful --save

To use in the browser, download the library from dist folder.

Usage

node.js

promiseful uses native ES2015 Promise.

To use non-native, 3rd-party Promise libraries, like bluebird or Promise polyfill, call promiseful.promise() with the Promise object, before using the API.

e.g.:

var Promise = require('bluebird');
// var Promise = require('es6-promise');
// var Promise = require('pinkie-promise');

var promiseful = require('promiseful');

promiseful.promise(Promise);

See example

Browser

promiseful uses native ES2015 Promise.

To use non-native, 3rd-party Promise libraries, like bluebird or Promise polyfill, include the library, before including promiseful.

e.g.:

<script src="https://cdn.jsdelivr.net/bluebird/latest/bluebird.min.js"></script>
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/es6-promise/4.1.0/es6-promise.min.js"></script> -->
<script src="promiseful.js"></script>

See example

API

A promiseful function is a function that returns a Promise.

e.g.:

function readPasswd() {
  return new Promise((resolve, reject) => {
    fs.readFile('/etc/passwd', (err, data) => {
      if (err) {
        reject(err);
      } else {
        resolve(data);
      }
    });
  });
}

The API works with promiseful functions. Do not pass Promise objects.

Methods follow pattern, similar to the excellent caolan/async library.

API Documentation

API

Examples

Node.js

  • server-time
  • es5

Browser

License

MIT

Keywords

promise

FAQs

Package last updated on 26 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