gads
Version:
An unofficial JS client library for the SOAP-based DFP Ads API
34 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const constants_1 = require("./constants");
// Waits for the promise to resolve and:
// - Iff callback provided: runs callback and returns void
// - Iff no callback provided: returns the promise
function callbackOrPromise(
// tslint:disable-next-line:no-any
cb, promise) {
if (!cb) {
return promise;
}
promise.then((res) => {
// tslint:disable-next-line
const args = (res instanceof Array) ? res : [res];
cb.call(cb, null, ...args);
}, err => cb(err));
}
exports.callbackOrPromise = callbackOrPromise;
// Generates a library signature suitable for a user agent field
// Returns: A library signature string to append to user-supplied user-agent value
function generateLibSig(
// The short, product-specific string name for the library
shortName) {
return ` (${shortName}, ${constants_1.COMMON_LIB_SIG}, ${constants_1.NODE_VERSION})`;
}
exports.generateLibSig = generateLibSig;
function timeout(ms) {
return new Promise(resolve => {
setTimeout(() => resolve(), ms);
});
}
exports.timeout = timeout;
//# sourceMappingURL=util.js.map