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

52 lines (51 loc) 1.56 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; Object.defineProperty(exports, "__esModule", { value: true }); function Map(init) { if (init === void 0) { init = {}; } this.storage = init; } exports.JMap = Map; Map.prototype = { put: function (key, value) { this.storage[key] = value; }, get: function (key) { return this.storage[key]; }, keys: function () { return Object.keys(this.storage); }, values: function () { var _this = this; return Object.keys(this.storage).map(function (key) { return _this.storage[key]; }); }, containsKey: function (key) { return Object.prototype.hasOwnProperty.call(this.storage, key); }, containsValue: function (value) { return this.values().some(function (v) { return v === value; }); }, entries: function () { var _this = this; return this.keys().map(function (k) { return ({ key: k, value: _this.storage[k] }); }); }, size: function () { return this.keys().length; }, toObject: function () { return __assign({}, this.storage); } };