• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..18-Dec-2021-

README.mdH A D18-Dec-20212 KiB4932

package.jsonH A D18-Dec-2021853 3534

README.md

1# async-value-promise
2
3An `AsyncValuePromise` represents a value that will exist in the future. It is
4similar to a `Promise` but does not include error boundary zoning or forced
5asynchrony, for performance reasons.
6
7This module is internally synchronous. What this means is that if a value
8promise has already had `resolve` or `reject` called, any calls to `then` will
9trigger the corresponding callback immediately. Conversely, if any callbacks
10have already been attached with `then` before a `resolve` or `reject` occurs
11they too will run immediately. This is intentional for performance reasons.
12
13## Install
14
15```sh
16npm install async-value-promise
17```
18
19## Usage
20
21```js
22var pass = new AsyncValuePromise()
23
24pass.then(name => {
25  console.log(`hello, ${name}!`)
26})
27
28pass.resolve('world')
29
30var fail = new AsyncValuePromise()
31
32fail.then(null, error => {
33  console.error(err.stack)
34})
35
36fail.reject(new Error('oops'))
37```
38
39---
40
41### Copyright (c) 2018 Stephen Belanger
42#### Licensed under MIT License
43
44Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
45
46The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
47
48THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
49