UNPKG

@rimbu/proximity

Version:

Immutable ProximityMap implementation for TypeScript

116 lines 4.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProximityMapNonEmpty = void 0; var tslib_1 = require("tslib"); var common_1 = require("@rimbu/common"); var common_2 = require("@rimbu/proximity/common"); var wrapping_cjs_1 = require("../wrapping.cjs"); var toStringBeginning = /^[^(]+/; var ProximityMapNonEmpty = /** @class */ (function () { function ProximityMapNonEmpty(context, internalMap) { this.context = context; this.internalMap = internalMap; this.isEmpty = false; } ProximityMapNonEmpty.prototype.plugInternalMap = function (newInternalMap) { if (newInternalMap == this.internalMap) { return this; } return (0, wrapping_cjs_1.wrapHashMap)(this.context, newInternalMap); }; Object.defineProperty(ProximityMapNonEmpty.prototype, "size", { get: function () { return this.internalMap.size; }, enumerable: false, configurable: true }); ProximityMapNonEmpty.prototype.stream = function () { return this.internalMap.stream(); }; ProximityMapNonEmpty.prototype.addEntries = function (entries) { return this.plugInternalMap(this.internalMap.addEntries(entries)); }; ProximityMapNonEmpty.prototype.updateAt = function (key, update) { return this.plugInternalMap(this.internalMap.updateAt(key, update)); }; ProximityMapNonEmpty.prototype.nonEmpty = function () { return true; }; ProximityMapNonEmpty.prototype.assumeNonEmpty = function () { return this; }; ProximityMapNonEmpty.prototype.asNormal = function () { return this; }; ProximityMapNonEmpty.prototype.streamKeys = function () { return this.internalMap.streamKeys(); }; ProximityMapNonEmpty.prototype.streamValues = function () { return this.internalMap.streamValues(); }; ProximityMapNonEmpty.prototype.mapValues = function (mapFun) { return new ProximityMapNonEmpty(this.context, this.internalMap.mapValues(mapFun)); }; ProximityMapNonEmpty.prototype.toArray = function () { return this.internalMap.toArray(); }; ProximityMapNonEmpty.prototype.get = function (key, otherwise) { var keyMatch = (0, common_2.findNearestKeyMatch)(this.context.distanceFunction, key, this.internalMap); return keyMatch ? keyMatch.value : (0, common_1.OptLazy)(otherwise); }; ProximityMapNonEmpty.prototype.hasKey = function (key) { return this.internalMap.hasKey(key); }; ProximityMapNonEmpty.prototype.removeKey = function (key) { return this.plugInternalMap(this.internalMap.removeKey(key)); }; ProximityMapNonEmpty.prototype.removeKeys = function (keys) { return this.plugInternalMap(this.internalMap.removeKeys(keys)); }; ProximityMapNonEmpty.prototype.removeKeyAndGet = function (key) { var internalResult = this.internalMap.removeKeyAndGet(key); if (!internalResult) { return undefined; } var _a = tslib_1.__read(internalResult, 2), newInternalMap = _a[0], value = _a[1]; return [this.plugInternalMap(newInternalMap), value]; }; ProximityMapNonEmpty.prototype.forEach = function (f, options) { if (options === void 0) { options = {}; } return this.internalMap.forEach(f, options); }; ProximityMapNonEmpty.prototype.filter = function (pred, options) { if (options === void 0) { options = {}; } return this.plugInternalMap(this.internalMap.filter(pred, options)); }; ProximityMapNonEmpty.prototype.toString = function () { return this.internalMap .toString() .replace(toStringBeginning, this.context.typeTag); }; ProximityMapNonEmpty.prototype.toJSON = function () { return { dataType: this.context.typeTag, value: this.toArray(), }; }; ProximityMapNonEmpty.prototype[Symbol.iterator] = function () { return this.internalMap[Symbol.iterator](); }; ProximityMapNonEmpty.prototype.set = function (key, value) { return this.plugInternalMap(this.internalMap.set(key, value)); }; ProximityMapNonEmpty.prototype.addEntry = function (entry) { return this.plugInternalMap(this.internalMap.addEntry(entry)); }; ProximityMapNonEmpty.prototype.modifyAt = function (atKey, options) { return this.plugInternalMap(this.internalMap.modifyAt(atKey, options)); }; ProximityMapNonEmpty.prototype.toBuilder = function () { return this.context.createBuilder(this); }; return ProximityMapNonEmpty; }()); exports.ProximityMapNonEmpty = ProximityMapNonEmpty; //# sourceMappingURL=NonEmpty.cjs.map