A suite to track Project Diva score statistics and ratings / D4DJ event data.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
projectdivar/server/node_modules/pg-promise/lib/promise-parser.js

56 lines
1.6 KiB

/*
* Copyright (c) 2015-present, Vitaly Tomilov
*
* See the LICENSE file at the top-level directory of this distribution
* for licensing information.
*
* Removal or modification of this copyright notice is prohibited.
*/
const {PromiseAdapter} = require(`./promise-adapter`);
//////////////////////////////////////////
// Parses and validates a promise library;
function parse(pl) {
let promise;
if (pl instanceof PromiseAdapter) {
promise = function (func) {
return pl.create(func);
};
promise.resolve = pl.resolve;
promise.reject = pl.reject;
promise.all = pl.all;
return promise;
}
const t = typeof pl;
if (t === `function` || t === `object`) {
const Root = typeof pl.Promise === `function` ? pl.Promise : pl;
promise = function (func) {
return new Root(func);
};
promise.resolve = Root.resolve;
promise.reject = Root.reject;
promise.all = Root.all;
if (typeof promise.resolve === `function` &&
typeof promise.reject === `function` &&
typeof promise.all === `function`) {
return promise;
}
}
throw new TypeError(`Invalid promise library specified.`);
}
function parsePromise(promiseLib) {
const result = {promiseLib};
if (promiseLib) {
result.promise = parse(promiseLib);
} else {
result.promise = parse(Promise);
result.promiseLib = Promise;
}
return result;
}
module.exports = {parsePromise};