Ignore:
Timestamp:
11/25/21 22:08:24 (3 years ago)
Author:
Ema <ema_spirova@…>
Branches:
master
Children:
8d391a1
Parents:
59329aa
Message:

primeNG components

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trip-planner-front/node_modules/pify/readme.md

    r59329aa re29cc2e  
    22
    33> Promisify a callback-style function
     4
     5---
     6
     7<div align="center">
     8        <b>
     9                <a href="https://tidelift.com/subscription/pkg/npm-pify?utm_source=npm-pify&utm_medium=referral&utm_campaign=readme">Get professional support for 'pify' with a Tidelift subscription</a>
     10        </b>
     11        <br>
     12        <sub>
     13                Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
     14        </sub>
     15</div>
     16
     17---
    418
    519
     
    721
    822```
    9 $ npm install --save pify
     23$ npm install pify
    1024```
    1125
     
    1731const pify = require('pify');
    1832
    19 // promisify a single function
    20 
     33// Promisify a single function
    2134pify(fs.readFile)('package.json', 'utf8').then(data => {
    2235        console.log(JSON.parse(data).name);
     
    2437});
    2538
    26 // or promisify all methods in a module
    27 
     39// Promisify all methods in a module
    2840pify(fs).readFile('package.json', 'utf8').then(data => {
    2941        console.log(JSON.parse(data).name);
     
    3547## API
    3648
    37 ### pify(input, [promiseModule], [options])
     49### pify(input, [options])
    3850
    39 Returns a promise wrapped version of the supplied function or module.
     51Returns a `Promise` wrapped version of the supplied function or module.
    4052
    4153#### input
    4254
    43 Type: `function`, `object`
     55Type: `Function` `Object`
    4456
    4557Callback-style function or module whose methods you want to promisify.
    46 
    47 #### promiseModule
    48 
    49 Type: `function`
    50 
    51 Custom promise module to use instead of the native one.
    52 
    53 Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.
    5458
    5559#### options
     
    5761##### multiArgs
    5862
    59 Type: `boolean` 
     63Type: `boolean`<br>
    6064Default: `false`
    6165
    62 By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument.
     66By default, the promisified function will only return the second argument from the callback, which works fine for most APIs. This option can be useful for modules like `request` that return multiple arguments. Turning this on will make it return an array of all arguments from the callback, excluding the error argument, instead of just the second argument. This also applies to rejections, where it returns an array of all the callback arguments, including the error.
    6367
    6468```js
     
    7377##### include
    7478
    75 Type: `array` of (`string`|`regex`)
     79Type: `string[]` `RegExp[]`
    7680
    7781Methods in a module to promisify. Remaining methods will be left untouched.
     
    7983##### exclude
    8084
    81 Type: `array` of (`string`|`regex`) 
    82 Default: `[/.+Sync$/]`
     85Type: `string[]` `RegExp[]`<br>
     86Default: `[/.+(Sync|Stream)$/]`
    8387
    8488Methods in a module **not** to promisify. Methods with names ending with `'Sync'` are excluded by default.
     
    8690##### excludeMain
    8791
    88 Type: `boolean` 
     92Type: `boolean`<br>
    8993Default: `false`
    9094
    91 By default, if given module is a function itself, this function will be promisified. Turn this option on if you want to promisify only methods of the module.
     95If given module is a function itself, it will be promisified. Turn this option on if you want to promisify only methods of the module.
    9296
    9397```js
     
    100104fn.method = (data, callback) => {
    101105        setImmediate(() => {
    102                 callback(data, null);
     106                callback(null, data);
    103107        });
    104108};
    105109
    106 // promisify methods but not fn()
     110// Promisify methods but not `fn()`
    107111const promiseFn = pify(fn, {excludeMain: true});
    108112
     
    114118```
    115119
     120##### errorFirst
     121
     122Type: `boolean`<br>
     123Default: `true`
     124
     125Whether the callback has an error as the first argument. You'll want to set this to `false` if you're dealing with an API that doesn't have an error as the first argument, like `fs.exists()`, some browser APIs, Chrome Extension APIs, etc.
     126
     127##### promiseModule
     128
     129Type: `Function`
     130
     131Custom promise module to use instead of the native one.
     132
     133Check out [`pinkie-promise`](https://github.com/floatdrop/pinkie-promise) if you need a tiny promise polyfill.
     134
     135
     136## Related
     137
     138- [p-event](https://github.com/sindresorhus/p-event) - Promisify an event by waiting for it to be emitted
     139- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
     140- [More…](https://github.com/sindresorhus/promise-fun)
     141
    116142
    117143## License
    118144
    119 MIT © [Sindre Sorhus](http://sindresorhus.com)
     145MIT © [Sindre Sorhus](https://sindresorhus.com)
Note: See TracChangeset for help on using the changeset viewer.