mirror of
https://github.com/actions/labeler
synced 2026-05-06 19:57:47 +02:00
build
This commit is contained in:
30
node_modules/util.promisify/implementation.js
generated
vendored
30
node_modules/util.promisify/implementation.js
generated
vendored
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
var isES5 = typeof Object.defineProperty === 'function'
|
||||
&& typeof Object.defineProperties === 'function'
|
||||
&& typeof Object.getPrototypeOf === 'function'
|
||||
&& typeof Object.setPrototypeOf === 'function';
|
||||
&& typeof Object.defineProperties === 'function';
|
||||
|
||||
if (!isES5) {
|
||||
throw new TypeError('util.promisify requires a true ES5 environment');
|
||||
var hasProto = [].__proto__ === Array.prototype; // eslint-disable-line no-proto
|
||||
|
||||
if (!isES5 || !hasProto) {
|
||||
throw new TypeError('util.promisify requires a true ES5 environment, that also supports `__proto__`');
|
||||
}
|
||||
|
||||
var getOwnPropertyDescriptors = require('object.getownpropertydescriptors');
|
||||
@@ -15,11 +15,13 @@ if (typeof Promise !== 'function') {
|
||||
throw new TypeError('`Promise` must be globally available for util.promisify to work.');
|
||||
}
|
||||
|
||||
var slice = Function.call.bind(Array.prototype.slice);
|
||||
var concat = Function.call.bind(Array.prototype.concat);
|
||||
var forEach = Function.call.bind(Array.prototype.forEach);
|
||||
var callBound = require('es-abstract/helpers/callBound');
|
||||
|
||||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol('') === 'symbol';
|
||||
var $slice = callBound('Array.prototype.slice');
|
||||
var $concat = callBound('Array.prototype.concat');
|
||||
var $forEach = callBound('Array.prototype.forEach');
|
||||
|
||||
var hasSymbols = require('has-symbols')();
|
||||
|
||||
var kCustomPromisifiedSymbol = hasSymbols ? Symbol('util.promisify.custom') : null;
|
||||
var kCustomPromisifyArgsSymbol = hasSymbols ? Symbol('customPromisifyArgs') : null;
|
||||
@@ -51,16 +53,16 @@ module.exports = function promisify(orig) {
|
||||
var argumentNames = orig[kCustomPromisifyArgsSymbol];
|
||||
|
||||
var promisified = function fn() {
|
||||
var args = slice(arguments);
|
||||
var args = $slice(arguments);
|
||||
var self = this; // eslint-disable-line no-invalid-this
|
||||
return new Promise(function (resolve, reject) {
|
||||
orig.apply(self, concat(args, function (err) {
|
||||
var values = arguments.length > 1 ? slice(arguments, 1) : [];
|
||||
orig.apply(self, $concat(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) {
|
||||
$forEach(argumentNames, function (name, index) {
|
||||
obj[name] = values[index];
|
||||
});
|
||||
resolve(obj);
|
||||
@@ -71,7 +73,7 @@ module.exports = function promisify(orig) {
|
||||
});
|
||||
};
|
||||
|
||||
Object.setPrototypeOf(promisified, Object.getPrototypeOf(orig));
|
||||
promisified.__proto__ = orig.__proto__; // eslint-disable-line no-proto
|
||||
|
||||
Object.defineProperty(promisified, kCustomPromisifiedSymbol, {
|
||||
configurable: true,
|
||||
|
||||
Reference in New Issue
Block a user