UNPKG

declarative-js

Version:

_declarative-js_ is modern JavaScript library, that helps to: - tackle array transformation with built in JavaScript array api (e.g. `array.filter(toBe.unique())`), - provide a type-level solution for representing optional values instead of null referen

30 lines (29 loc) 996 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function valid(key) { if (typeof key !== 'string') { throw new Error("Resolved key must be a string, actual: value - " + key + " type - " + typeof key); } return key; } exports.valid = valid; exports.IMMUTABLE = '_immutable'; exports.finalizeMap = function (map) { if (Object.getOwnPropertyDescriptor(map, exports.IMMUTABLE)) { Object.seal(map.storage); return map; } return map; }; exports.finalizeObject = function (object) { if (Object.getOwnPropertyDescriptor(object, exports.IMMUTABLE)) { return Object.seal(object); } return object; }; exports.isLastElement = function (array, index) { return array.length - 1 === index; }; // @ts-ignore function onDuplacateDefaultFunction(v1, v2, key) { throw new Error("Key: \"" + key + "\" has duplicates"); } exports.onDuplacateDefaultFunction = onDuplacateDefaultFunction;