|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
904 bytes
|
| Line | |
|---|
| 1 | # util.promisify
|
|---|
| 2 | Polyfill for util.promisify in node versions < v8
|
|---|
| 3 |
|
|---|
| 4 | node v8.0.0 added support for a built-in `util.promisify`: https://github.com/nodejs/node/pull/12442/
|
|---|
| 5 |
|
|---|
| 6 | This package provides the built-in `util.promisify` in node v8.0.0 and later, and a replacement in other environments.
|
|---|
| 7 |
|
|---|
| 8 | ## Usage
|
|---|
| 9 |
|
|---|
| 10 | **Direct**
|
|---|
| 11 | ```js
|
|---|
| 12 | const promisify = require('util.promisify');
|
|---|
| 13 | // Use `promisify` just like the built-in method on `util`
|
|---|
| 14 | ```
|
|---|
| 15 |
|
|---|
| 16 | **Shim**
|
|---|
| 17 | ```js
|
|---|
| 18 | require('util.promisify/shim')();
|
|---|
| 19 | // `util.promisify` is now defined
|
|---|
| 20 | const util = require('util');
|
|---|
| 21 | // Use `util.promisify`
|
|---|
| 22 | ```
|
|---|
| 23 |
|
|---|
| 24 | Note: this package requires a native ES5 environment, and for `Promise` to be globally available. It will throw upon requiring it if these are not present.
|
|---|
| 25 |
|
|---|
| 26 | ## Promisifying modules
|
|---|
| 27 |
|
|---|
| 28 | If you want to promisify a whole module, like the `fs` module, you can use [`util.promisify-all`](https://www.npmjs.com/package/util.promisify-all).
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.