@openland/foundationdb-core
Version:
Node.js bindings for the FoundationDB database
41 lines • 1.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.eachOption = (data, _opts, iterfn) => {
const opts = _opts;
for (const k in opts) {
const details = data[k];
if (details == null) {
// tslint:disable:no-console
console.warn('Warning: Ignoring unknown option', k);
// tslint:enable:no-console
continue;
}
const { code, type } = details;
const userVal = opts[k];
switch (type) {
case 'none':
if (userVal !== true && userVal !== 1) {
// tslint:disable:no-console
console.warn(`Warning: Ignoring value ${userVal} for option ${k}`);
// tslint:enable:no-console
}
iterfn(details.code, null);
break;
case 'string':
case 'bytes':
iterfn(details.code, Buffer.from(userVal));
break;
case 'int':
if (typeof userVal !== 'number') {
// tslint:disable:no-console
console.warn('unexpected value for key', k, 'expected int');
// tslint:enable:no-console
}
iterfn(details.code, userVal | 0);
break;
default:
break;
}
}
};
//# sourceMappingURL=opts.js.map