Initial Save
This commit is contained in:
17
node_modules/util.promisify/.eslintrc
generated
vendored
Normal file
17
node_modules/util.promisify/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"root": true,
|
||||
|
||||
"extends": "@ljharb",
|
||||
|
||||
"rules": {
|
||||
"id-length": [2, { "min": 1, "max": 30 }],
|
||||
"max-lines-per-function": 0,
|
||||
"multiline-comment-style": 0,
|
||||
"new-cap": [2, {
|
||||
"capIsNewExceptions": [
|
||||
"GetIntrinsic",
|
||||
],
|
||||
}],
|
||||
"no-magic-numbers": 0,
|
||||
}
|
||||
}
|
||||
12
node_modules/util.promisify/.github/FUNDING.yml
generated
vendored
Normal file
12
node_modules/util.promisify/.github/FUNDING.yml
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: [ljharb]
|
||||
patreon: # Replace with a single Patreon username
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: # Replace with a single Ko-fi username
|
||||
tidelift: npm/util.promisify
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
13
node_modules/util.promisify/.nycrc
generated
vendored
Normal file
13
node_modules/util.promisify/.nycrc
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"all": true,
|
||||
"check-coverage": false,
|
||||
"reporter": ["text-summary", "text", "html", "json"],
|
||||
"lines": 86,
|
||||
"statements": 85.93,
|
||||
"functions": 82.43,
|
||||
"branches": 76.06,
|
||||
"exclude": [
|
||||
"coverage",
|
||||
"test"
|
||||
]
|
||||
}
|
||||
123
node_modules/util.promisify/CHANGELOG.md
generated
vendored
Normal file
123
node_modules/util.promisify/CHANGELOG.md
generated
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [v1.1.3](https://github.com/ljharb/util.promisify/compare/v1.1.2...v1.1.3) - 2024-12-18
|
||||
|
||||
### Commits
|
||||
|
||||
- [Robustness]: use `call-bind`, `define-data-property`, `es-errors`, `es-object-atoms`, `get-intrinsic` [`f3b4baa`](https://github.com/ljharb/util.promisify/commit/f3b4baaebf234621f88af5dd4b5513b4be540d97)
|
||||
- [actions] split out node 10-20, and 20+ [`fda95ae`](https://github.com/ljharb/util.promisify/commit/fda95ae91df65fef2c4909a54a2cf26ddb3bdf5d)
|
||||
- [Tests] test with both disable-proto options [`509cfcb`](https://github.com/ljharb/util.promisify/commit/509cfcbe5d869e0b1a867ebd78acb86138e156ad)
|
||||
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `auto-changelog`, `npmignore`, `tape` [`3712bb5`](https://github.com/ljharb/util.promisify/commit/3712bb5ae38f0dc86a198d7fb61a0c225c1bce20)
|
||||
- [Deps] update `call-bind`, `has-proto`, `has-symbols`, `object.getownpropertydescriptors`, `safe-array-concat` [`4d1441e`](https://github.com/ljharb/util.promisify/commit/4d1441e0d9cd3ecd92954d8d6bf9ed2a6989f594)
|
||||
- [Deps] update `define-properties`, `object.getownpropertydescriptors`, `safe-array-concat` [`47a969e`](https://github.com/ljharb/util.promisify/commit/47a969e5e202be2f0978cc21028831bc34151d52)
|
||||
- [Refactor] use `call-bound` directly [`48dba6c`](https://github.com/ljharb/util.promisify/commit/48dba6c1dbe3edb7c8b03515836711924b68f5e8)
|
||||
- [Dev Deps] update `aud`, `tape` [`7aa0c21`](https://github.com/ljharb/util.promisify/commit/7aa0c21777de3e0eb72db07cbb599239fdf9699e)
|
||||
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config` [`0817cfd`](https://github.com/ljharb/util.promisify/commit/0817cfde128e90a8722533118e2adee28aac87fd)
|
||||
- [meta] add missing `engines.node` [`9d08241`](https://github.com/ljharb/util.promisify/commit/9d082412e7063c22d98504d73028782a3b67ca73)
|
||||
- [Tests] replace `aud` with `npm audit` [`cf287ac`](https://github.com/ljharb/util.promisify/commit/cf287aca6a4b33d629254173b7d9f2c6ad3e9eed)
|
||||
- [Dev Deps] add missing peer dep [`fb9e435`](https://github.com/ljharb/util.promisify/commit/fb9e435973d1d773c59c3b3f906ca80d7ceda894)
|
||||
|
||||
## [v1.1.2](https://github.com/ljharb/util.promisify/compare/v1.1.1...v1.1.2) - 2023-04-20
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Fix] avoid crashing with `--disable-proto=throw` [`#26`](https://github.com/ljharb/util.promisify/issues/26)
|
||||
|
||||
### Commits
|
||||
|
||||
- [actions] reuse common workflows [`2736cb6`](https://github.com/ljharb/util.promisify/commit/2736cb6c8ea7c1cfeca6ddc3c9cf1615aab9a1a8)
|
||||
- [meta] use `npmignore` to autogenerate an npmignore file [`0eb5abb`](https://github.com/ljharb/util.promisify/commit/0eb5abbe3d3e78fccd20c9f6cac665a7687b54b8)
|
||||
- [meta] reorganize package.json [`e610642`](https://github.com/ljharb/util.promisify/commit/e610642b27f1498a2114d970ce327b29cfd3bde6)
|
||||
- [Fix] proper error name [`727c30c`](https://github.com/ljharb/util.promisify/commit/727c30c330b829ee5946226f69b114fae9c761cf)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `@es-shims/api`, `aud`, `auto-changelog`, `safe-publish-latest`, `tape` [`ecc9281`](https://github.com/ljharb/util.promisify/commit/ecc9281821e111f04c3f57e5f28e01386721da30)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog`, `tape` [`91c385d`](https://github.com/ljharb/util.promisify/commit/91c385d7c500678ae87c9b022cc5003815b2bf89)
|
||||
- [actions] update rebase action [`c62f4bf`](https://github.com/ljharb/util.promisify/commit/c62f4bfac476b1cdf4836d2e554dca712e2552b8)
|
||||
- [Refactor] use `has-proto` [`e423ed0`](https://github.com/ljharb/util.promisify/commit/e423ed024de422aa75264f2cfd13a16455da2fc4)
|
||||
- [Dev Deps] update `@es-shims/api`, `ljharb/eslint-config`,` aud`, `tape` [`62717c1`](https://github.com/ljharb/util.promisify/commit/62717c13f97227771f0b72c3d0638976d04e472a)
|
||||
- [Refactor] use `safe-array-concat` [`d068529`](https://github.com/ljharb/util.promisify/commit/d068529b46fbff46960111dfe857d43734f3a0f1)
|
||||
- [Deps] update `define-properties`, `has-symbols`, `object.getownpropertydescriptors` [`bd8a7be`](https://github.com/ljharb/util.promisify/commit/bd8a7be795d349176a667a69755a6472facbb2af)
|
||||
- [Deps] update `call-bind`, `has-symbols`, `object.getownpropertydescriptors` [`7473409`](https://github.com/ljharb/util.promisify/commit/7473409dbc10974549a869c8bed8172342a40728)
|
||||
- [Deps] update `define-properties`, `object.getownpropertydescriptors` [`4f244be`](https://github.com/ljharb/util.promisify/commit/4f244beb8e8f51011f265bef0bb87e2a8972f320)
|
||||
|
||||
## [v1.1.1](https://github.com/ljharb/util.promisify/compare/v1.1.0...v1.1.1) - 2021-01-08
|
||||
|
||||
### Commits
|
||||
|
||||
- [Fix] add missing runtime dependency `has-symbols` [`9b45a3b`](https://github.com/ljharb/util.promisify/commit/9b45a3bfbc0bcf5e474e1d045aacca3dc9609e54)
|
||||
|
||||
## [v1.1.0](https://github.com/ljharb/util.promisify/compare/v1.0.1...v1.1.0) - 2021-01-06
|
||||
|
||||
### Commits
|
||||
|
||||
- [Tests] migrate tests to Github Actions [`a09e2f5`](https://github.com/ljharb/util.promisify/commit/a09e2f5cc3590c3098681c98b08dcb15b5c0877b)
|
||||
- [Tests] add tests [`5162b64`](https://github.com/ljharb/util.promisify/commit/5162b642805030b7d83e978e73392213d0b2431a)
|
||||
- [meta] do not publish github action workflow files [`4b5a39e`](https://github.com/ljharb/util.promisify/commit/4b5a39ed1df1c6ce86fb687f7494882fd29099ba)
|
||||
- [Fix] handle nonconfigurable own function properties, in older engines [`07693ae`](https://github.com/ljharb/util.promisify/commit/07693ae63cdc71d88c2203d62aca53623fba4815)
|
||||
- [New] use a global symbol for `util.promisify.custom` [`8f8631b`](https://github.com/ljharb/util.promisify/commit/8f8631b04c3f2cf1bd082837c8d73431e356eb2f)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `aud`, `auto-changelog` [`83e7267`](https://github.com/ljharb/util.promisify/commit/83e7267f27e38a9abcba6803f945c71a68255ff9)
|
||||
- [actions] add "Allow Edits" workflow [`e2a92ae`](https://github.com/ljharb/util.promisify/commit/e2a92ae988554713f89e62fcbf0ac602f76976f6)
|
||||
- [Tests] move `es-shim-api` to `postlint` [`7b93efa`](https://github.com/ljharb/util.promisify/commit/7b93efacd4c978b76d02be9b33b94b61ee366e65)
|
||||
- [Deps] use `call-bind` instead of `es-abstract` [`e68f500`](https://github.com/ljharb/util.promisify/commit/e68f500d9dd0cdd0563d72b758e34bdf1bed0d6c)
|
||||
- [actions] switch Automatic Rebase workflow to `pull_request_target` event [`7da936c`](https://github.com/ljharb/util.promisify/commit/7da936c0681062c5eb812185ebc9ccf4d86851c5)
|
||||
- [Dev Deps] update `aud`, `auto-changelog` [`88465d4`](https://github.com/ljharb/util.promisify/commit/88465d4202969895123e3113db3e8b45972ca2f6)
|
||||
- [Tests] only audit prod deps [`8a13dc5`](https://github.com/ljharb/util.promisify/commit/8a13dc5192ab899034e1f78151324ea06fb381b1)
|
||||
- [Deps] update `object.getownpropertydescriptors` [`899d30b`](https://github.com/ljharb/util.promisify/commit/899d30b3389b033b3964dd0e7faa0469db8b3ba4)
|
||||
- [Deps] update `es-abstract` [`552d18b`](https://github.com/ljharb/util.promisify/commit/552d18b34ebc0eda0d0bc33a84ca1827aa86aaf9)
|
||||
- [Dev Deps] update `auto-changelog` [`dd61917`](https://github.com/ljharb/util.promisify/commit/dd61917fabad7c8c4c52807ca4b5b40611a14e62)
|
||||
- [Deps] update `es-abstract` [`40a839a`](https://github.com/ljharb/util.promisify/commit/40a839a8db3d79699688d27f6613a827056428c8)
|
||||
- [Dev Deps] update `@ljharb/eslint-config` [`07c3b39`](https://github.com/ljharb/util.promisify/commit/07c3b3952682e9c4d58b6bfb9404049827b5c523)
|
||||
|
||||
## [v1.0.1](https://github.com/ljharb/util.promisify/compare/v1.0.0...v1.0.1) - 2020-01-16
|
||||
|
||||
### Fixed
|
||||
|
||||
- [Refactor] remove unnecessary duplication. Fixes #3. [`#3`](https://github.com/ljharb/util.promisify/issues/3)
|
||||
|
||||
### Commits
|
||||
|
||||
- [Tests] use shared travis-ci configs [`f1b5e43`](https://github.com/ljharb/util.promisify/commit/f1b5e43359e74a30f35bd10a33be765de73917c6)
|
||||
- [Tests] up to `node` `v10.0`, `v9.11`, `v8.11`, `v6.14`, `4.9`; use `nvm install-latest-npm`; pin included builds to LTS [`e89390f`](https://github.com/ljharb/util.promisify/commit/e89390f498f7eb5111188fff5260cbb9f5216cd3)
|
||||
- [meta] add `auto-changelog` [`fe8e751`](https://github.com/ljharb/util.promisify/commit/fe8e751819a1318d3c929b086c70308aed50715d)
|
||||
- [Tests] up to `node` `v11.0`, `v10.12`, `v8.12` [`e09b894`](https://github.com/ljharb/util.promisify/commit/e09b894291aef2991e5c553f0b64968e03b58262)
|
||||
- [Refactor] use `callBound` helper from `es-abstract` for robustness [`baa0cf6`](https://github.com/ljharb/util.promisify/commit/baa0cf697068573cbe650e01aa6774154dd3f454)
|
||||
- [actions] add automatic rebasing / merge commit blocking [`24912f4`](https://github.com/ljharb/util.promisify/commit/24912f41b30d88b8984fb07307f737de6f576873)
|
||||
- [Docs] Add usage information for the shim/monkey-patch [`38b1ee5`](https://github.com/ljharb/util.promisify/commit/38b1ee56b558019213a6fdc2553796e8cdaf773e)
|
||||
- [Refactor] use `__proto__` instead of ES6’s `Object.setPrototypeOf` [`02ec7e2`](https://github.com/ljharb/util.promisify/commit/02ec7e241caf8848c1e141c801f98ed31325b59a)
|
||||
- [meta] create FUNDING.yml [`076b8b5`](https://github.com/ljharb/util.promisify/commit/076b8b5d19783a0e4c932e41782846e431deeb7d)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` [`4cedaa9`](https://github.com/ljharb/util.promisify/commit/4cedaa9c6b0a77a0416b69d480b3b806c00dec6e)
|
||||
- Adds usage information to the README [`ddb4556`](https://github.com/ljharb/util.promisify/commit/ddb45562320ab8aea93dc0364640ea21ab68bfbb)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config`, `safe-publish-latest` [`95362c0`](https://github.com/ljharb/util.promisify/commit/95362c0e93186a30ede6333430ddfa0606a769b4)
|
||||
- [Dev Deps] update `@es-shims/api`, `@ljharb/eslint-config`, `eslint` [`fd79a58`](https://github.com/ljharb/util.promisify/commit/fd79a58573186c83d81777fa0b1ad293b2f475e3)
|
||||
- [Dev Deps] update `eslint`, `@ljharb/eslint-config` [`2cf792b`](https://github.com/ljharb/util.promisify/commit/2cf792b9dcaab24b642ef1de8239ceb089fc5d38)
|
||||
- [Docs] Link to util.promisify-all [`032ff5c`](https://github.com/ljharb/util.promisify/commit/032ff5c6ee2958a02f56c770337441c3a587b88c)
|
||||
- [Tests] allow node 0.10 and 0.8 to fail again [`c2f8418`](https://github.com/ljharb/util.promisify/commit/c2f8418dfc36b83cd8a18b86a735c2936c6f5f9e)
|
||||
- [Tests] remove mistakenly added travis jobs [`13a242f`](https://github.com/ljharb/util.promisify/commit/13a242fb33dcbd4e2872436f2e430e62526fb147)
|
||||
- [Tests] on `node` `v10.1` [`8244578`](https://github.com/ljharb/util.promisify/commit/82445786197fd3e54aeffaa2fe0f1da38bcafec4)
|
||||
- [meta] add `funding` field [`e1645ca`](https://github.com/ljharb/util.promisify/commit/e1645ca10648d1ae917e3f5ae954b37de338dc20)
|
||||
- [New] add `auto` entry point [`2c48047`](https://github.com/ljharb/util.promisify/commit/2c480479d67646fb2bfb92a4e5d50ff14bcdca3c)
|
||||
- [Fix] use `has-symbols` package to ensure we support Symbol shams too. [`75135c8`](https://github.com/ljharb/util.promisify/commit/75135c8a48ea4e1be1cfe7a95af11905818303e7)
|
||||
- [Deps] update `es-abstract` [`32aa5cc`](https://github.com/ljharb/util.promisify/commit/32aa5ccd3ee7513edef99ed7d516d6c0f4901883)
|
||||
- [Dev Deps] update `eslint` [`c3043e6`](https://github.com/ljharb/util.promisify/commit/c3043e6e562847102e9136479268777bc07e9b26)
|
||||
- [Deps] update `object.getownpropertydescriptors` [`521ed25`](https://github.com/ljharb/util.promisify/commit/521ed25d40dc230b38ac3755036219fbaf94694c)
|
||||
- [Deps] update `has-symbol` [`16d91ec`](https://github.com/ljharb/util.promisify/commit/16d91ecc0016c31e49b7c3da938c19132c243732)
|
||||
- [Deps] update `define-properties` [`532915e`](https://github.com/ljharb/util.promisify/commit/532915ed58fe6f0edc3670837b510e09fb39b99a)
|
||||
- [Tests] `npm` v5+ breaks on node < v4 [`0647c63`](https://github.com/ljharb/util.promisify/commit/0647c63d932451c043c3e8f3b003c636057f035a)
|
||||
|
||||
## v1.0.0 - 2017-05-30
|
||||
|
||||
### Commits
|
||||
|
||||
- Dotfiles. [`02c20cb`](https://github.com/ljharb/util.promisify/commit/02c20cb4eb01cf656102f57f71635785114f1d09)
|
||||
- Initial implementation. [`05ff048`](https://github.com/ljharb/util.promisify/commit/05ff0480448f019a85675ce81ecc4e9bdc099286)
|
||||
- Initial commit [`9472155`](https://github.com/ljharb/util.promisify/commit/947215502491bb1b3238aa0ac5c67258e41db3a8)
|
||||
- package.json [`e0302c0`](https://github.com/ljharb/util.promisify/commit/e0302c01e5e3b1dd78647303f9a4337b5bb63196)
|
||||
- Initial readme. [`5df78e1`](https://github.com/ljharb/util.promisify/commit/5df78e16e89e8328c61d6bbac85409a36560fe3b)
|
||||
- [Dev Deps] add `safe-publish-latest` [`596b6b4`](https://github.com/ljharb/util.promisify/commit/596b6b4fbce79dbaf5fff366454ab5b31d2eb993)
|
||||
- [Tests] add `npm run lint` [`54c2ccb`](https://github.com/ljharb/util.promisify/commit/54c2ccb85db682fc293b30a0bfece76d0a5c7c60)
|
||||
- [Dev Deps] add `@es-shims/api` [`d9014f1`](https://github.com/ljharb/util.promisify/commit/d9014f12add2fb3fe743647df614c69ed305a824)
|
||||
- [Tests] allow 0.10 and 0.8 to fail, for now. [`c5c7b61`](https://github.com/ljharb/util.promisify/commit/c5c7b619b88878fc715d1768b48bd45378c9f807)
|
||||
21
node_modules/util.promisify/LICENSE
generated
vendored
Normal file
21
node_modules/util.promisify/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Jordan Harband
|
||||
|
||||
Permission 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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE 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.
|
||||
28
node_modules/util.promisify/README.md
generated
vendored
Normal file
28
node_modules/util.promisify/README.md
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# util.promisify
|
||||
Polyfill for util.promisify in node versions < v8
|
||||
|
||||
node v8.0.0 added support for a built-in `util.promisify`: https://github.com/nodejs/node/pull/12442/
|
||||
|
||||
This package provides the built-in `util.promisify` in node v8.0.0 and later, and a replacement in other environments.
|
||||
|
||||
## Usage
|
||||
|
||||
**Direct**
|
||||
```js
|
||||
const promisify = require('util.promisify');
|
||||
// Use `promisify` just like the built-in method on `util`
|
||||
```
|
||||
|
||||
**Shim**
|
||||
```js
|
||||
require('util.promisify/shim')();
|
||||
// `util.promisify` is now defined
|
||||
const util = require('util');
|
||||
// Use `util.promisify`
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
## Promisifying modules
|
||||
|
||||
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).
|
||||
3
node_modules/util.promisify/auto.js
generated
vendored
Normal file
3
node_modules/util.promisify/auto.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
require('./shim')();
|
||||
122
node_modules/util.promisify/implementation.js
generated
vendored
Normal file
122
node_modules/util.promisify/implementation.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
'use strict';
|
||||
|
||||
var forEach = require('for-each');
|
||||
|
||||
var $Object = require('es-object-atoms');
|
||||
|
||||
var isES5 = typeof $Object.defineProperty === 'function';
|
||||
|
||||
var gPO = $Object.getPrototypeOf;
|
||||
var sPO = $Object.setPrototypeOf;
|
||||
// eslint-disable-next-line global-require
|
||||
var hasProto = require('has-proto')() || (typeof gPO === 'function' && gPO([]) === Array.prototype);
|
||||
|
||||
if (!isES5 || !hasProto) {
|
||||
throw new TypeError('util.promisify requires a true ES5+ environment, that also supports `__proto__` and/or `Object.getPrototypeOf`');
|
||||
}
|
||||
|
||||
var getOwnPropertyDescriptors = require('object.getownpropertydescriptors');
|
||||
|
||||
if (typeof Promise !== 'function') {
|
||||
throw new TypeError('`Promise` must be globally available for util.promisify to work.');
|
||||
}
|
||||
|
||||
var GetIntrinsic = require('get-intrinsic');
|
||||
|
||||
var oDP = $Object.defineProperty;
|
||||
var $Promise = GetIntrinsic('%Promise%');
|
||||
var $TypeError = TypeError;
|
||||
|
||||
var safeConcat = require('safe-array-concat');
|
||||
var callBind = require('call-bind');
|
||||
var callBound = require('call-bound');
|
||||
var defineDataProperty = require('define-data-property');
|
||||
|
||||
var $slice = callBound('Array.prototype.slice');
|
||||
|
||||
var hasSymbols = require('has-symbols/shams')();
|
||||
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
var kCustomPromisifiedSymbol = hasSymbols ? Symbol['for']('nodejs.util.promisify.custom') : null;
|
||||
var kCustomPromisifyArgsSymbol = hasSymbols ? Symbol('customPromisifyArgs') : null;
|
||||
|
||||
module.exports = function promisify(orig) {
|
||||
if (typeof orig !== 'function') {
|
||||
var error = new $TypeError('The "original" argument must be of type function');
|
||||
error.code = 'ERR_INVALID_ARG_TYPE';
|
||||
error.toString = function value() {
|
||||
return this.name + '[' + this.code + ']: ' + this.message;
|
||||
};
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (hasSymbols && orig[kCustomPromisifiedSymbol]) {
|
||||
var customFunction = orig[kCustomPromisifiedSymbol];
|
||||
if (typeof customFunction !== 'function') {
|
||||
var customError = $TypeError('The [util.promisify.custom] property must be of type function.');
|
||||
customError.code = 'ERR_INVALID_ARG_TYPE';
|
||||
customError.toString = function value() {
|
||||
return this.name + '[' + this.code + ']: ' + this.message;
|
||||
};
|
||||
throw customError;
|
||||
}
|
||||
defineDataProperty(
|
||||
customFunction,
|
||||
kCustomPromisifiedSymbol,
|
||||
customFunction,
|
||||
true,
|
||||
true,
|
||||
null,
|
||||
true
|
||||
);
|
||||
return customFunction;
|
||||
}
|
||||
|
||||
// Names to create an object from in case the callback receives multiple
|
||||
// arguments, e.g. ['stdout', 'stderr'] for child_process.exec.
|
||||
var argumentNames = orig[kCustomPromisifyArgsSymbol];
|
||||
|
||||
var origApply = callBind.apply(orig);
|
||||
|
||||
var promisified = function fn() {
|
||||
var args = $slice(arguments);
|
||||
var self = this; // eslint-disable-line no-invalid-this
|
||||
return new $Promise(function (resolve, reject) {
|
||||
origApply(self, safeConcat(args, function (err) {
|
||||
var values = arguments.length > 1 ? $slice(arguments, 1) : [];
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else if (typeof argumentNames !== 'undefined' && values.length > 1) {
|
||||
var obj = {};
|
||||
forEach(argumentNames, function (name, index) {
|
||||
obj[name] = values[index];
|
||||
});
|
||||
resolve(obj);
|
||||
} else {
|
||||
resolve(values[0]);
|
||||
}
|
||||
}));
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof sPO === 'function' && typeof gPO === 'function') {
|
||||
sPO(promisified, gPO(orig));
|
||||
} else {
|
||||
promisified.__proto__ = orig.__proto__; // eslint-disable-line no-proto
|
||||
}
|
||||
|
||||
defineDataProperty(promisified, kCustomPromisifiedSymbol, promisified, true, true, null, true);
|
||||
|
||||
var descriptors = getOwnPropertyDescriptors(orig);
|
||||
forEach(descriptors, function (k, v) {
|
||||
try {
|
||||
oDP(promisified, k, v);
|
||||
} catch (e) {
|
||||
// handle nonconfigurable function properties
|
||||
}
|
||||
});
|
||||
return promisified;
|
||||
};
|
||||
|
||||
module.exports.custom = kCustomPromisifiedSymbol;
|
||||
module.exports.customPromisifyArgs = kCustomPromisifyArgsSymbol;
|
||||
24
node_modules/util.promisify/index.js
generated
vendored
Normal file
24
node_modules/util.promisify/index.js
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
'use strict';
|
||||
|
||||
var define = require('define-properties');
|
||||
var util = require('util');
|
||||
|
||||
var implementation = require('./implementation');
|
||||
var getPolyfill = require('./polyfill');
|
||||
var polyfill = getPolyfill();
|
||||
var shim = require('./shim');
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
var boundPromisify = function promisify(orig) {
|
||||
/* eslint-enable no-unused-vars */
|
||||
return polyfill.apply(util, arguments);
|
||||
};
|
||||
define(boundPromisify, {
|
||||
custom: polyfill.custom,
|
||||
customPromisifyArgs: polyfill.customPromisifyArgs,
|
||||
getPolyfill: getPolyfill,
|
||||
implementation: implementation,
|
||||
shim: shim
|
||||
});
|
||||
|
||||
module.exports = boundPromisify;
|
||||
82
node_modules/util.promisify/package.json
generated
vendored
Normal file
82
node_modules/util.promisify/package.json
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "util.promisify",
|
||||
"version": "1.1.3",
|
||||
"description": "Polyfill/shim for util.promisify in node versions < v8",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"prepack": "npmignore --auto --commentLines=autogenerated",
|
||||
"prepublishOnly": "safe-publish-latest",
|
||||
"prepublish": "not-in-publish || npm run prepublishOnly",
|
||||
"lint": "eslint --ext=js,mjs.",
|
||||
"postlint": "es-shim-api --bound",
|
||||
"pretest": "npm run lint",
|
||||
"tests-only": "nyc tape 'test/**/*.js'",
|
||||
"test": "npm run tests-only",
|
||||
"posttest": "npx npm@'>= 10.2' audit --production",
|
||||
"version": "auto-changelog && git add CHANGELOG.md",
|
||||
"postversion": "auto-changelog && git add CHANGELOG.md && git commit --no-edit --amend && git tag -f \"v$(node -e \"console.log(require('./package.json').version)\")\""
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/ljharb/util.promisify.git"
|
||||
},
|
||||
"keywords": [
|
||||
"promisify",
|
||||
"promise",
|
||||
"util",
|
||||
"polyfill",
|
||||
"shim",
|
||||
"util.promisify"
|
||||
],
|
||||
"author": "Jordan Harband <ljharb@gmail.com>",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/ljharb/util.promisify/issues"
|
||||
},
|
||||
"homepage": "https://github.com/ljharb/util.promisify#readme",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.8",
|
||||
"call-bound": "^1.0.3",
|
||||
"define-data-property": "^1.1.4",
|
||||
"define-properties": "^1.2.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.0.0",
|
||||
"for-each": "^0.3.3",
|
||||
"get-intrinsic": "^1.2.6",
|
||||
"has-proto": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"object.getownpropertydescriptors": "^2.1.8",
|
||||
"safe-array-concat": "^1.1.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@es-shims/api": "^2.5.1",
|
||||
"@ljharb/eslint-config": "^21.1.1",
|
||||
"auto-changelog": "^2.5.0",
|
||||
"encoding": "^0.1.13",
|
||||
"eslint": "=8.8.0",
|
||||
"in-publish": "^2.0.1",
|
||||
"npmignore": "^0.3.1",
|
||||
"nyc": "^10.3.2",
|
||||
"safe-publish-latest": "^2.0.0",
|
||||
"tape": "^5.9.0"
|
||||
},
|
||||
"auto-changelog": {
|
||||
"output": "CHANGELOG.md",
|
||||
"template": "keepachangelog",
|
||||
"unreleased": false,
|
||||
"commitLimit": false,
|
||||
"backfillLimit": false,
|
||||
"hideCredit": true
|
||||
},
|
||||
"publishConfig": {
|
||||
"ignore": [
|
||||
".github/workflows"
|
||||
]
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
}
|
||||
11
node_modules/util.promisify/polyfill.js
generated
vendored
Normal file
11
node_modules/util.promisify/polyfill.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var implementation = require('./implementation');
|
||||
|
||||
module.exports = function getPolyfill() {
|
||||
if (typeof util.promisify === 'function' && util.promisify.custom === implementation.custom) {
|
||||
return util.promisify;
|
||||
}
|
||||
return implementation;
|
||||
};
|
||||
17
node_modules/util.promisify/shim.js
generated
vendored
Normal file
17
node_modules/util.promisify/shim.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var getPolyfill = require('./polyfill');
|
||||
|
||||
module.exports = function shimUtilPromisify() {
|
||||
var polyfill = getPolyfill();
|
||||
if (polyfill !== util.promisify) {
|
||||
Object.defineProperty(util, 'promisify', {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
value: polyfill,
|
||||
writable: true
|
||||
});
|
||||
}
|
||||
return polyfill;
|
||||
};
|
||||
21
node_modules/util.promisify/test/implementation.js
generated
vendored
Normal file
21
node_modules/util.promisify/test/implementation.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('implementation', function (t) {
|
||||
/* eslint global-require: 1 */
|
||||
if (typeof Promise === 'function') {
|
||||
var promisify = require('../implementation');
|
||||
runTests(promisify, t);
|
||||
} else {
|
||||
t['throws'](
|
||||
function () { require('../implementation'); },
|
||||
TypeError,
|
||||
'throws when no Promise available'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
21
node_modules/util.promisify/test/index.js
generated
vendored
Normal file
21
node_modules/util.promisify/test/index.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('as a function', function (t) {
|
||||
/* eslint global-require: 1 */
|
||||
if (typeof Promise === 'function') {
|
||||
var promisify = require('../');
|
||||
runTests(promisify, t);
|
||||
} else {
|
||||
t['throws'](
|
||||
function () { require('../'); },
|
||||
TypeError,
|
||||
'throws when no Promise available'
|
||||
);
|
||||
}
|
||||
|
||||
t.end();
|
||||
});
|
||||
14
node_modules/util.promisify/test/shimmed.js
generated
vendored
Normal file
14
node_modules/util.promisify/test/shimmed.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var util = require('util');
|
||||
|
||||
var runTests = require('./tests');
|
||||
|
||||
test('shimmed', { skip: typeof Promise !== 'function' }, function (t) {
|
||||
require('../auto'); // eslint-disable-line global-require
|
||||
|
||||
runTests(util.promisify, t);
|
||||
|
||||
t.end();
|
||||
});
|
||||
54
node_modules/util.promisify/test/tests.js
generated
vendored
Normal file
54
node_modules/util.promisify/test/tests.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
'use strict';
|
||||
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
module.exports = function runTests(promisify, t) {
|
||||
t.equal(typeof promisify, 'function', 'promisify is a function');
|
||||
|
||||
t['throws'](
|
||||
function () { promisify(null); },
|
||||
TypeError,
|
||||
'throws on non-functions'
|
||||
);
|
||||
|
||||
var yes = function () {
|
||||
var cb = arguments[arguments.length - 1];
|
||||
cb(null, Array.prototype.slice.call(arguments, 0, -1));
|
||||
};
|
||||
var no = function () {
|
||||
var cb = arguments[arguments.length - 1];
|
||||
cb(Array.prototype.slice.call(arguments, 0, -1));
|
||||
};
|
||||
|
||||
var pYes = promisify(yes);
|
||||
var pNo = promisify(no);
|
||||
|
||||
t.equal(typeof pYes, 'function', 'pYes is a function');
|
||||
t.equal(typeof pNo, 'function', 'pNo is a function');
|
||||
|
||||
t.test('pYes is properly promisified', { skip: typeof Promise !== 'function' }, function (st) {
|
||||
st.plan(1);
|
||||
|
||||
var p = pYes(1, 2, 3);
|
||||
return p.then(function (result) {
|
||||
st.deepEqual(result, [1, 2, 3], 'fulfillment: arguments are preserved');
|
||||
});
|
||||
});
|
||||
|
||||
t.test('pNo is properly promisified', { skip: typeof Promise !== 'function' }, function (st) {
|
||||
st.plan(1);
|
||||
|
||||
var p = pNo(1, 2, 3);
|
||||
return p.then(null, function (args) {
|
||||
st.deepEqual(args, [1, 2, 3], 'rejection: arguments are preserved');
|
||||
});
|
||||
});
|
||||
|
||||
t.test('custom symbol', { skip: !hasSymbols }, function (st) {
|
||||
st.equal(Symbol.keyFor(promisify.custom), 'nodejs.util.promisify.custom', 'is a global symbol with the right key');
|
||||
// eslint-disable-next-line no-restricted-properties
|
||||
st.equal(Symbol['for']('nodejs.util.promisify.custom'), promisify.custom, 'is the global symbol');
|
||||
|
||||
st.end();
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user