vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
22 lines (21 loc) • 820 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.assertHookReturnedObject = assertHookReturnedObject;
const utils_js_1 = require("./utils.js");
function assertHookReturnedObject(obj, keysExpected, errPrefix) {
(0, utils_js_1.assert)(!errPrefix.endsWith(' '));
const keysUnknown = [];
const keys = Object.keys(obj);
for (const key of keys) {
if (!keysExpected.includes(key)) {
keysUnknown.push(key);
}
}
(0, utils_js_1.assertUsage)(keysUnknown.length === 0, [
errPrefix,
'returned an object with following unknown keys:',
(0, utils_js_1.stringifyStringArray)(keysUnknown) + '.',
'Only following keys are allowed:',
(0, utils_js_1.stringifyStringArray)(keysExpected) + '.',
].join(' '));
}