source: trip-planner-front/node_modules/pinkie/readme.md@ eed0bf8

Last change on this file since eed0bf8 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.6 KB
RevLine 
[6a3a178]1<h1 align="center">
2 <br>
3 <img width="256" src="media/logo.png" alt="pinkie">
4 <br>
5 <br>
6</h1>
7
8> Itty bitty little widdle twinkie pinkie [ES2015 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation
9
10[![Build Status](https://travis-ci.org/floatdrop/pinkie.svg?branch=master)](https://travis-ci.org/floatdrop/pinkie) [![Coverage Status](https://coveralls.io/repos/floatdrop/pinkie/badge.svg?branch=master&service=github)](https://coveralls.io/github/floatdrop/pinkie?branch=master)
11
12There are [tons of Promise implementations](https://github.com/promises-aplus/promises-spec/blob/master/implementations.md#standalone) out there, but all of them focus on browser compatibility and are often bloated with functionality.
13
14This module is an exact Promise specification polyfill (like [native-promise-only](https://github.com/getify/native-promise-only)), but in Node.js land (it should be browserify-able though).
15
16
17## Install
18
19```
20$ npm install --save pinkie
21```
22
23
24## Usage
25
26```js
27var fs = require('fs');
28var Promise = require('pinkie');
29
30new Promise(function (resolve, reject) {
31 fs.readFile('foo.json', 'utf8', function (err, data) {
32 if (err) {
33 reject(err);
34 return;
35 }
36
37 resolve(data);
38 });
39});
40//=> Promise
41```
42
43
44### API
45
46`pinkie` exports bare [ES2015 Promise](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-promise-objects) implementation and polyfills [Node.js rejection events](https://nodejs.org/api/process.html#process_event_unhandledrejection). In case you forgot:
47
48#### new Promise(executor)
49
50Returns new instance of `Promise`.
51
52##### executor
53
54*Required*
55Type: `function`
56
57Function with two arguments `resolve` and `reject`. The first argument fulfills the promise, the second argument rejects it.
58
59#### pinkie.all(promises)
60
61Returns a promise that resolves when all of the promises in the `promises` Array argument have resolved.
62
63#### pinkie.race(promises)
64
65Returns a promise that resolves or rejects as soon as one of the promises in the `promises` Array resolves or rejects, with the value or reason from that promise.
66
67#### pinkie.reject(reason)
68
69Returns a Promise object that is rejected with the given `reason`.
70
71#### pinkie.resolve(value)
72
73Returns a Promise object that is resolved with the given `value`. If the `value` is a thenable (i.e. has a then method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the `value`.
74
75
76## Related
77
78- [pinkie-promise](https://github.com/floatdrop/pinkie-promise) - Returns the native Promise or this module
79
80
81## License
82
83MIT © [Vsevolod Strukchinsky](http://github.com/floatdrop)
Note: See TracBrowser for help on using the repository browser.