nav tabs on admin dashboard
This commit is contained in:
127
node_modules/util/util.js
generated
vendored
127
node_modules/util/util.js
generated
vendored
@@ -19,6 +19,16 @@
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors ||
|
||||
function getOwnPropertyDescriptors(obj) {
|
||||
var keys = Object.keys(obj);
|
||||
var descriptors = {};
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]);
|
||||
}
|
||||
return descriptors;
|
||||
};
|
||||
|
||||
var formatRegExp = /%[sdj%]/g;
|
||||
exports.format = function(f) {
|
||||
if (!isString(f)) {
|
||||
@@ -63,17 +73,17 @@ exports.format = function(f) {
|
||||
// Returns a modified function which warns once by default.
|
||||
// If --no-deprecation is set, then it is a no-op.
|
||||
exports.deprecate = function(fn, msg) {
|
||||
if (typeof process !== 'undefined' && process.noDeprecation === true) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
// Allow for deprecating things in the process of starting up.
|
||||
if (isUndefined(global.process)) {
|
||||
if (typeof process === 'undefined') {
|
||||
return function() {
|
||||
return exports.deprecate(fn, msg).apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
if (process.noDeprecation === true) {
|
||||
return fn;
|
||||
}
|
||||
|
||||
var warned = false;
|
||||
function deprecated() {
|
||||
if (!warned) {
|
||||
@@ -584,3 +594,110 @@ exports._extend = function(origin, add) {
|
||||
function hasOwnProperty(obj, prop) {
|
||||
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||
}
|
||||
|
||||
var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined;
|
||||
|
||||
exports.promisify = function promisify(original) {
|
||||
if (typeof original !== 'function')
|
||||
throw new TypeError('The "original" argument must be of type Function');
|
||||
|
||||
if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) {
|
||||
var fn = original[kCustomPromisifiedSymbol];
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('The "util.promisify.custom" argument must be of type Function');
|
||||
}
|
||||
Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
||||
value: fn, enumerable: false, writable: false, configurable: true
|
||||
});
|
||||
return fn;
|
||||
}
|
||||
|
||||
function fn() {
|
||||
var promiseResolve, promiseReject;
|
||||
var promise = new Promise(function (resolve, reject) {
|
||||
promiseResolve = resolve;
|
||||
promiseReject = reject;
|
||||
});
|
||||
|
||||
var args = [];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
args.push(function (err, value) {
|
||||
if (err) {
|
||||
promiseReject(err);
|
||||
} else {
|
||||
promiseResolve(value);
|
||||
}
|
||||
});
|
||||
|
||||
try {
|
||||
original.apply(this, args);
|
||||
} catch (err) {
|
||||
promiseReject(err);
|
||||
}
|
||||
|
||||
return promise;
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(fn, Object.getPrototypeOf(original));
|
||||
|
||||
if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, {
|
||||
value: fn, enumerable: false, writable: false, configurable: true
|
||||
});
|
||||
return Object.defineProperties(
|
||||
fn,
|
||||
getOwnPropertyDescriptors(original)
|
||||
);
|
||||
}
|
||||
|
||||
exports.promisify.custom = kCustomPromisifiedSymbol
|
||||
|
||||
function callbackifyOnRejected(reason, cb) {
|
||||
// `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
|
||||
// Because `null` is a special error value in callbacks which means "no error
|
||||
// occurred", we error-wrap so the callback consumer can distinguish between
|
||||
// "the promise rejected with null" or "the promise fulfilled with undefined".
|
||||
if (!reason) {
|
||||
var newReason = new Error('Promise was rejected with a falsy value');
|
||||
newReason.reason = reason;
|
||||
reason = newReason;
|
||||
}
|
||||
return cb(reason);
|
||||
}
|
||||
|
||||
function callbackify(original) {
|
||||
if (typeof original !== 'function') {
|
||||
throw new TypeError('The "original" argument must be of type Function');
|
||||
}
|
||||
|
||||
// We DO NOT return the promise as it gives the user a false sense that
|
||||
// the promise is actually somehow related to the callback's execution
|
||||
// and that the callback throwing will reject the promise.
|
||||
function callbackified() {
|
||||
var args = [];
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
args.push(arguments[i]);
|
||||
}
|
||||
|
||||
var maybeCb = args.pop();
|
||||
if (typeof maybeCb !== 'function') {
|
||||
throw new TypeError('The last argument must be of type Function');
|
||||
}
|
||||
var self = this;
|
||||
var cb = function() {
|
||||
return maybeCb.apply(self, arguments);
|
||||
};
|
||||
// In true node style we process the callback on `nextTick` with all the
|
||||
// implications (stack, `uncaughtException`, `async_hooks`)
|
||||
original.apply(this, args)
|
||||
.then(function(ret) { process.nextTick(cb, null, ret) },
|
||||
function(rej) { process.nextTick(callbackifyOnRejected, rej, cb) });
|
||||
}
|
||||
|
||||
Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original));
|
||||
Object.defineProperties(callbackified,
|
||||
getOwnPropertyDescriptors(original));
|
||||
return callbackified;
|
||||
}
|
||||
exports.callbackify = callbackify;
|
||||
|
||||
Reference in New Issue
Block a user