@bemoje/map 2.1.2 → 2.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +3 -3
- package/lib/index.cjs.map +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/package.json +2 -2
package/lib/index.cjs
CHANGED
|
@@ -129,10 +129,10 @@ __name(reduceIterableValues, "reduceIterableValues");
|
|
|
129
129
|
function toObjectIterable(mapLike) {
|
|
130
130
|
const object = {};
|
|
131
131
|
for (const [key, value] of mapLike) {
|
|
132
|
-
if (typeof key
|
|
133
|
-
object[String(key)] = value;
|
|
134
|
-
} else {
|
|
132
|
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
135
133
|
object[key] = value;
|
|
134
|
+
} else {
|
|
135
|
+
object[String(key)] = value;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
return object;
|
package/lib/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../object/src/defineMethod.ts","../../../object/src/entriesOf.ts","../../../composition/src/View.ts","../../../composition/src/inheritProxifiedPrototypeProperty.ts","../../../composition/src/inheritProxifiedPrototype.ts","../../src/entriesArray.ts","../../../iter/src/filterIterableValues.ts","../../../iter/src/mapIterableKeys.ts","../../../iter/src/mapIterableValues.ts","../../../iter/src/reduceIterableValues.ts","../../../iter/src/toObjectIterable.ts","../../src/keysArray.ts","../../src/mapGetOrDefault.ts","../../src/mapLoad.ts","../../src/mapReverse.ts","../../src/mapUpdate.ts","../../src/sort.ts","../../src/sortByKeys.ts","../../src/sortByValues.ts","../../../fn/src/setNameAndLength.ts","../../../fn/src/thisify.ts","../../../fn/src/transformReturnValue.ts","../../src/toMap.ts","../../src/valuesArray.ts","../../src/ExtMap.ts","../../src/TimeoutWeakMap.ts","../../src/countUniques.ts","../../src/isGenericMap.ts"],"names":["defineMethod","obj","key","value","des","Object","defineProperty","configurable","writable","enumerable","entriesOf","entries","TARGET_SYMBOL","View","target","Symbol","toStringTag","name","inheritProxifiedPrototypeProperty","ViewerClass","TargetClass","Reflect","getOwnPropertyDescriptor","prototype","args","get","set","undefined","inheritProxifiedPrototype","omitKeys","ownKeys","filter","k","includes","forEach","entriesArray","ins","Array","from","filterIterableValues","mapLike","predicate","v","mapIterableKeys","mapper","map","mapIterableValues","reduceIterableValues","reducer","initial","accumulator","toObjectIterable","object","String","keysArray","keys","mapGetOrDefault","factory","has","mapLoad","mapReverse","reverse","clear","mapUpdate","update","newValue","sort","compare","sortByKeys","a","b","sortByValues","setNameAndLength","source","lengthDelta","defineProperties","length","thisify","fn","f","transformReturnValue","transform","result","apply","toMap","Map","valuesArray","values","ExtMap","arg","isIterable","fromObject","fromIterable","clone","toJSON","inspect","custom","_depth","_options","breakLength","TimeoutWeakMap","wmap","WeakMap","timeoutMs","vt","timeout","refresh","setTimeout","delete","unref","clearTimeout","load","getOrDefault","countUniques","input","reduce","MultiSet","acc","imp","add","multiplicities","isGenericMap","requiredProps","every","prop"],"mappings":";;;;;;;;;;AAMO,SAASA,aACdC,GAAAA,EACAC,GAAAA,EACAC,KAAAA,EACAC,GAAAA,GAAkD,EAAC,EAAC;AAEpD,EAAA,OAAOC,MAAAA,CAAOC,cAAAA,CAAkBL,GAAAA,EAAKC,GAAAA,EAAK;AACxCC,IAAAA,KAAAA;IACAI,YAAAA,EAAc,IAAA;IACdC,QAAAA,EAAU,IAAA;IACVC,UAAAA,EAAY,KAAA;IACZ,GAAGL;GACL,CAAA;AACF;AAbgBJ,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;;;ACDT,SAASU,UAA4BT,GAAAA,EAAM;AAChD,EAAA,OAAOI,MAAAA,CAAOM,QAAQV,GAAAA,CAAAA;AACxB;AAFgBS,MAAAA,CAAAA,SAAAA,EAAAA,WAAAA,CAAAA;;;ACHhB,IAAME,aAAAA,0BAAuB,QAAA,CAAA;AAKtB,IAAMC,OAAN,MAA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AAGC,CAAAA,KAAMA,CAAAA,GAAID,CAAAA,CAAAA;AAC/B;AARgB4C,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;;;ACJT,SAASQ,YAAAA,CACd3G,QACA4G,aAAAA,GAAuB;AAAC,EAAA,KAAA;AAAO,EAAA,KAAA;AAAO,EAAA;AAA0B,CAAA,EAAA;AAEhE,EAAA,OAAO,CAAC,CAAC5G,MAAAA,IAAU4G,aAAAA,CAAcC,MAAM,CAACC,IAAAA,KAAS,OAAQ9G,MAAAA,CAAiB8G,IAAAA,CAAAA,KAAU,OAAOvC,GAAAA,CAAI9D,SAAAA,CAAUqG,IAAAA,CAAK,CAAA;AAChH;AALgBH,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"index.cjs","sourcesContent":["import type { AccessorDescriptor } from './isAccessorDescriptor'\nimport type { ValueDescriptor } from './isValueDescriptor'\n\n/**\n * Define a method property on an object with enhanced descriptor handling.\n */\nexport function defineMethod<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n value: V,\n des: ValueDescriptor<T> | AccessorDescriptor<T> = {}\n) {\n return Object.defineProperty<T>(obj, key, {\n value,\n configurable: true,\n writable: true,\n enumerable: false,\n ...des,\n })\n}\n","import type { StringKeyOf } from '@mono/types'\n\n/**\n * Same as Object.entries except the keys are typed as keyof T.\n */\nexport function entriesOf<T extends object>(obj: T): [StringKeyOf<T>, T[StringKeyOf<T>]][] {\n return Object.entries(obj) as [StringKeyOf<T>, T[StringKeyOf<T>]][]\n}\n","import type { IView } from './IView'\n\nconst TARGET_SYMBOL = Symbol('target')\n\n/**\n * Base class providing view functionality over a target object using the Composition pattern.\n */\nexport class View<Target extends object> implements IView<Target> {\n private [TARGET_SYMBOL]: Target\n\n constructor(target: Target) {\n this[TARGET_SYMBOL] = target\n }\n\n get [Symbol.toStringTag](): string {\n return this.constructor.name\n }\n\n get target(): Target {\n return this[TARGET_SYMBOL]\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\n\n/**\n * Inherits a single prototype property from a target class to a viewer class with proxification.\n */\nexport function inheritProxifiedPrototypeProperty<Viewer extends IView<Target>, Target extends object>(\n ViewerClass: Class<Viewer>,\n TargetClass: Class<Target>,\n key: keyof Target\n) {\n const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key)\n if (!des) {\n return\n }\n\n if (des.value && typeof des.value === 'function') {\n return Object.defineProperty(ViewerClass.prototype, key, {\n value(...args: any[]) {\n return this.target[key](...args)\n },\n writable: true,\n configurable: true,\n enumerable: false,\n })\n } else if (des && !des.get && !des.set) {\n return Object.defineProperty(ViewerClass.prototype, key, {\n get(this: Viewer) {\n return this.target[key]\n },\n set: des.writable\n ? function set(this: Viewer, value: Target[keyof Target]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n } else {\n Object.defineProperty(ViewerClass.prototype, key, {\n get: des.get\n ? function (this: Viewer) {\n return this.target[key]\n }\n : undefined,\n set: des.set\n ? function (this: Viewer, value: Target[typeof key]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\nimport { inheritProxifiedPrototypeProperty } from './inheritProxifiedPrototypeProperty'\n\n/**\n * Inherits prototype properties from a target class to a viewer class with proxification, excluding specified keys.\n */\nexport function inheritProxifiedPrototype<\n Viewer extends IView<Target>,\n Target extends object,\n Omitted extends PropertyKey[] = [],\n>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, omitKeys: Omitted) {\n Reflect.ownKeys(TargetClass.prototype)\n .filter((k) => k !== 'constructor' && k !== Symbol.toStringTag)\n .filter((k) => (omitKeys ? !omitKeys.includes(k) : true))\n .forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k as keyof Target))\n return ViewerClass as typeof ViewerClass & { prototype: Viewer & Omit<Target, Omitted[number]> }\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all key-value pairs in the map.\n * Convenience method that converts the entries iterator to an array.\n *\n * @returns Array of all key-value pairs\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function entriesArray<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): [K, V][] {\n return Array.from(ins)\n}\n","import { filter } from 'iter-tools'\n\n/**\n * Filter an iterable of key-value entries based on a predicate function that tests values.\n *\n * @param mapLike - An iterable of key-value tuples to filter\n * @param predicate - A function that tests each value. Returns `true` to keep the entry, `false` otherwise.\n * @returns An iterable containing only the entries whose values satisfy the predicate\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const filtered = filterIterableValues(entries, (value) => value > 1)\n * // filtered: Iterable of [['b', 2], ['c', 3]]\n * ```\n */\nexport function filterIterableValues<K, V, V2 extends V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => value is V2\n): Iterable<[K, V2]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]> {\n return filter(([k, v]: [K, V]) => predicate(v, k), mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the keys in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each key\n * @returns An iterable containing entries with transformed keys\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableKeys(entries, (key) => key.toUpperCase())\n * // mapped: Iterable of [['A', 1], ['B', 2], ['C', 3]]\n * ```\n */\nexport function mapIterableKeys<K, V, K2>(\n mapLike: Iterable<[K, V]>,\n mapper: (key: K, value: V) => K2\n): Iterable<[K2, V]> {\n return map(([k, v]: [K, V]) => [mapper(k, v), v] as [K2, V], mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the values in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each value\n * @returns An iterable containing entries with transformed values\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableValues(entries, (value) => value * 2)\n * // mapped: Iterable of [['a', 2], ['b', 4], ['c', 6]]\n * ```\n */\nexport function mapIterableValues<K, V, V2>(\n mapLike: Iterable<[K, V]>,\n mapper: (value: V, key: K) => V2\n): Iterable<[K, V2]> {\n return map(([k, v]: [K, V]) => [k, mapper(v, k)] as [K, V2], mapLike)\n}\n","/**\n * Reduce an iterable of key-value entries based on values using a reducer function.\n *\n * @param mapLike - An iterable of key-value tuples to reduce\n * @param reducer - A function that combines values\n * @param initial - The initial value for the reduction\n * @returns The reduced value\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const sum = reduceIterableValues(entries, (acc, value, key) => acc + value, 0)\n * // sum: 6\n * ```\n */\nexport function reduceIterableValues<K, V, R>(\n mapLike: Iterable<[K, V]>,\n reducer: (accumulator: R, value: V, key: K) => R,\n initial: R\n): R {\n let accumulator = initial\n for (const [k, v] of mapLike) {\n accumulator = reducer(accumulator, v, k)\n }\n return accumulator\n}\n","/**\n * Convert a map-like iterable to a regular object.\n */\nexport function toObjectIterable<K extends string, V>(mapLike: Iterable<[K, V]>): Record<K, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>): Record<Extract<K, string> | string, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>) {\n const object = {} as Record<PropertyKey, V>\n for (const [key, value] of mapLike) {\n if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'symbol') {\n object[String(key)] = value\n } else {\n object[key] = value\n }\n }\n return object\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all keys in the map.\n * Convenience method that converts the keys iterator to an array.\n *\n * @returns Array of all keys\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(keysArray(map)) // ['a', 'b', 'c']\n * ```\n */\nexport function keysArray<K, V>(ins: GenericMap<K, V, 'keys'>): K[] {\n return Array.from(ins.keys())\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Gets a value from a map or creates it using a factory function if it doesn't exist.\n */\nexport function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(\n map: T,\n key: K,\n factory: (key: K, map: T) => V\n): V {\n let value = map.get(key)\n if (value !== undefined || map.has(key)) {\n return value as V\n }\n value = factory(key, map)\n map.set(key, value)\n return value\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Loads multiple entries into the map from an iterable.\n *\n * @param entries - An iterable of key-value pairs to load into the map\n * @returns The map instance for method chaining\n */\nexport function mapLoad<T extends GenericMap<K, V, 'set'>, K, V>(ins: T, entries: Iterable<[K, V]>): T {\n for (const [key, value] of entries) {\n ins.set(key, value)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\nimport { mapLoad } from './mapLoad'\n\n/**\n * Reverses the order of entries in a Map.\n * @remarks This function creates a new Map with the entries of the original Map in reverse order.\n * The original Map is not modified.\n * @example ```ts\n * mapReverse(new Map([['a', 1], ['b', 2], ['c', 3]]));\n * //=> [['c', 3], ['b', 2], ['a', 1]]\n * ```\n */\nexport function mapReverse<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T): T\nexport function mapReverse<K, V>(ins: Map<K, V>): Map<K, V>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapReverse<K, V>(ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>): any {\n const entries = Array.from(ins).reverse()\n ins.clear()\n mapLoad(ins, entries)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Updates a value in the map using an update function.\n *\n * @param key - The key to update\n * @param update - Function that receives the current value and returns the new value\n * @returns The map instance for method chaining\n */\nexport function mapUpdate<T extends GenericMap<K, V, 'set' | 'get'>, K, V>(\n ins: T,\n key: K,\n update: (value: V | undefined, key: K, map: T) => V\n): T\nexport function mapUpdate<K, V>(\n ins: Map<K, V>,\n key: K,\n update: (value: V | undefined, key: K, map: Map<K, V>) => V\n): typeof ins\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapUpdate<K, V>(ins: any, key: K, update: (value: V | undefined, key: K, map: any) => V) {\n const newValue = update(ins.get(key), key, ins)\n\n ins.set(key, newValue)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries using a custom comparison function and updates the map in place.\n * This is Map-specific because it maintains insertion order.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two entries\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sort(map, ([k1], [k2]) => k1.localeCompare(k2))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sort<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: [K, V], b: [K, V]) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort(compare)\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their keys and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two keys\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByKeys(map, (a, b) => a.localeCompare(b))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByKeys<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: K, b: K) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort((a, b) => compare(a[0], b[0]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their values and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two values\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByValues(map, (a, b) => a - b)\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByValues<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(\n ins: T,\n compare: (a: V, b: V) => number\n): T\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n const entries = Array.from(ins).sort((a, b) => compare(a[1], b[1]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { Any } from '@mono/types'\n\n/**\n * Preserves the name and length of a function or class constructor\n */\nexport function setNameAndLength<\n S extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n F extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n>(source: S, target: F, lengthDelta = 0): F {\n return Object.defineProperties(target, {\n name: { configurable: true, value: source.name }, //\n length: { configurable: true, value: source.length + lengthDelta },\n })\n}\n","import type { Any } from '@mono/types'\nimport type { ArraySlice } from 'type-fest'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Converts a function to a class method by making the 'this' context the first argument.\n */\nexport function thisify<T, Args extends Any[], Ret>(\n fn: (target: T, ...args: Args) => Ret\n): (this: T, ...args: Args) => Ret {\n return setNameAndLength(\n fn,\n function f(this: T, ...args: Args): Ret {\n return fn(this, ...args)\n },\n -1\n )\n}\n\nexport type Thisify<T extends object, F extends (target: T, ...args: any[]) => Any> = (\n this: T,\n ...args: ArraySlice<Parameters<F>, 1>\n) => ReturnType<F>\n","import { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wraps a function to transform its return value using a transform function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function transformReturnValue<T, Args extends any[], Ret, NewRet>(\n fn: (this: T, ...args: Args) => Ret,\n transform: (value: Ret) => NewRet\n): (this: T, ...args: Args) => NewRet {\n return setNameAndLength(fn, function (this: T, ...args: Args): NewRet {\n const result = fn.apply(this, args)\n return transform(result)\n })\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Converts a GenericMap to a native Map.\n *\n * @param ins - The GenericMap instance to convert\n * @returns A new native Map with the same entries\n *\n * @example\n * ```typescript\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * const nativeMap = toMap(extMap)\n * console.log(nativeMap instanceof Map) // true\n * ```\n */\nexport function toMap<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): Map<K, V> {\n return new Map(ins)\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all values in the map.\n * Convenience method that converts the values iterator to an array.\n *\n * @returns Array of all values\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(valuesArray(map)) // [1, 2, 3]\n * ```\n */\nexport function valuesArray<K, V>(ins: GenericMap<K, V, 'values'>): V[] {\n return Array.from(ins.values())\n}\n","import type { InspectOptions } from 'util'\nimport { View } from '@mono/composition'\nimport { defineMethod } from '@mono/object'\nimport { entriesArray } from './entriesArray'\nimport { entriesOf } from '@mono/object'\nimport { filterIterableValues } from '@mono/iter'\nimport { inheritProxifiedPrototype } from '@mono/composition'\nimport { inspect } from 'util'\nimport { isIterable } from 'iter-tools'\nimport { keysArray } from './keysArray'\nimport { mapGetOrDefault } from './mapGetOrDefault'\nimport { mapIterableKeys } from '@mono/iter'\nimport { mapIterableValues } from '@mono/iter'\nimport { mapLoad } from './mapLoad'\nimport { mapReverse } from './mapReverse'\nimport { mapUpdate } from './mapUpdate'\nimport { reduceIterableValues } from '@mono/iter'\nimport { sort } from './sort'\nimport { sortByKeys } from './sortByKeys'\nimport { sortByValues } from './sortByValues'\nimport { thisify } from '@mono/fn'\nimport { toMap } from './toMap'\nimport { toObjectIterable } from '@mono/iter'\nimport { transformReturnValue } from '@mono/fn'\nimport { valuesArray } from './valuesArray'\n\ndeclare module './ExtMap' {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export interface ExtMap<K = any, V = any> extends Map<K, V> {\n load(entries: Iterable<[K, V]>): this\n sort(compare: (a: [K, V], b: [K, V]) => number): this\n sortByKeys(compare: (a: K, b: K) => number): this\n sortByValues(compare: (a: V, b: V) => number): this\n reverse(): this\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this\n getOrDefault(key: K, factory: (key: K, map: this) => V): V\n keysArray(): K[]\n valuesArray(): V[]\n entriesArray(): [K, V][]\n toMap(): Map<K, V>\n toObject<K extends string, V>(): Record<K, V>\n toObject<K, V>(): Record<Extract<K, PropertyKey> | string, V>\n reduce<R>(reducer: (accumulator: R, value: V, key: K) => R, initialValue: R): R\n map<NewK, NewV>(mapper: (value: V, key: K) => [NewK, NewV]): ExtMap<NewK, NewV>\n mapKeys<NewK>(mapper: (key: K, value: V) => NewK): ExtMap<NewK, V>\n mapValues<NewV>(mapper: (value: V, key: K) => NewV): ExtMap<K, NewV>\n filter(predicate: (value: V, key: K) => boolean): ExtMap<K, V>\n }\n}\n\n/**\n * Minimal Extended Map class focused only on Map-specific utilities.\n *\n * @template K - The type of keys in the map\n * @template V - The type of values in the map\n *\n * @example\n * ```typescript\n * import { map as iterMap, filter } from 'iter-tools'\n *\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n * .update('a', v => (v ?? 0) + 10)\n * .sortByValues((a, b) => a - b)\n *\n * // Use iter-tools for transformations\n * const doubled = new ExtMap<string, number>()\n * .load(iterMap(([k, v]) => [k, v * 2], extMap))\n *\n * // Use iter-tools for filtering\n * const filtered = new ExtMap<string, number>()\n * .load(filter(([k, v]) => v > 5, extMap))\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ExtMap<K = any, V = any> extends View<Map<K, V>> implements Map<K, V> {\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined)\n constructor(obj?: Record<Extract<K, PropertyKey>, V>)\n constructor(arg?: Record<Extract<K, PropertyKey>, V> | Iterable<readonly [K, V]> | null | undefined) {\n super(new Map(isIterable(arg) ? arg : arg ? entriesOf(arg) : undefined))\n }\n\n /**\n * Creates a new ExtMap instance from a regular object.\n *\n * @param obj - An object whose key-value pairs will be used to initialize the map\n * @returns A new ExtMap instance containing the entries from the object\n */\n static fromObject<K extends PropertyKey, V>(obj: Record<K, V>): ExtMap<K, V> {\n return new ExtMap(Object.entries(obj)) as ExtMap<K, V>\n }\n\n /**\n * Creates a new ExtMap instance from an iterable of key-value pairs.\n *\n * @param entries - An iterable of key-value pairs to initialize the map\n * @returns A new ExtMap instance containing the provided entries\n */\n static fromIterable<K, V>(entries: Iterable<readonly [K, V]>): ExtMap<K, V> {\n return new ExtMap(entries)\n }\n\n /**\n * Creates a shallow copy of the map.\n *\n * @returns A new ExtMap instance with the same entries\n */\n clone(): ExtMap<K, V> {\n return new ExtMap(this)\n }\n\n /**\n * Converts the map to a JSON-serializable format.\n *\n * @returns Array of key-value pairs suitable for JSON serialization\n */\n toJSON(): [K, V][] {\n return [...this.entries()]\n }\n\n /**\n * Custom inspection method for better debugging output.\n *\n * @param _depth - The depth of inspection\n * @param _options - Options for inspection\n * @returns A string representation of the map\n */\n [inspect.custom](_depth: number, _options: InspectOptions): string {\n return inspect(this.target, { breakLength: 50 })\n }\n}\n\ninheritProxifiedPrototype(ExtMap, Map, [])\n\ndefineMethod(ExtMap.prototype, 'load', thisify(mapLoad))\ndefineMethod(ExtMap.prototype, 'sort', thisify(sort))\ndefineMethod(ExtMap.prototype, 'sortByKeys', thisify(sortByKeys))\ndefineMethod(ExtMap.prototype, 'sortByValues', thisify(sortByValues))\ndefineMethod(ExtMap.prototype, 'reverse', thisify(mapReverse))\ndefineMethod(ExtMap.prototype, 'update', thisify(mapUpdate))\ndefineMethod(ExtMap.prototype, 'getOrDefault', thisify(mapGetOrDefault))\ndefineMethod(ExtMap.prototype, 'keysArray', thisify(keysArray))\ndefineMethod(ExtMap.prototype, 'valuesArray', thisify(valuesArray))\ndefineMethod(ExtMap.prototype, 'entriesArray', thisify(entriesArray))\ndefineMethod(ExtMap.prototype, 'toObject', thisify(toObjectIterable))\ndefineMethod(ExtMap.prototype, 'toMap', thisify(toMap))\ndefineMethod(ExtMap.prototype, 'reduce', thisify(reduceIterableValues))\ndefineMethod(ExtMap.prototype, 'map', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapKeys', thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapValues', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'filter', thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)))\n","/**\n * A WeakMap with automatic timeout-based expiry for entries.\n *\n * Entries are automatically removed after a specified timeout period.\n * Accessing an entry refreshes its timeout, extending its lifetime.\n * This is useful for caching scenarios where you want automatic cleanup\n * of unused entries while keeping frequently accessed ones alive.\n */\nexport class TimeoutWeakMap<K extends object, V> {\n protected readonly wmap = new WeakMap<K, [V, NodeJS.Timeout]>()\n\n /**\n * @param timeoutMs Default timeout in milliseconds for entries\n */\n constructor(readonly timeoutMs: number) {}\n\n /**\n * Retrieves the value for the given key and refreshes its timeout.\n *\n * @param key The key to retrieve\n * @returns The value if found, undefined otherwise\n */\n get(key: K): V | undefined {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return undefined\n }\n const [value, timeout] = vt\n timeout.refresh()\n return value\n }\n\n /**\n * Sets a key-value pair with an optional custom timeout.\n *\n * @param key The key to set\n * @param value The value to associate with the key\n * @param timeoutMs Optional timeout override for this entry\n * @returns This instance for chaining\n */\n set(key: K, value: V, timeoutMs?: number): this {\n this.wmap.set(key, [\n value,\n setTimeout(() => {\n this.delete(key)\n }, timeoutMs ?? this.timeoutMs).unref(),\n ])\n return this\n }\n\n /**\n * Removes a key-value pair and clears its timeout.\n *\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: K): boolean {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return false\n }\n const timeout = vt[1]\n clearTimeout(timeout)\n return this.wmap.delete(key)\n }\n\n /**\n * Checks if a key exists in the map.\n * Does not refresh the timeout.\n *\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: K): boolean {\n return this.wmap.has(key)\n }\n\n /**\n * Loads multiple key-value pairs into the map.\n *\n * @param entries Iterable of key-value pairs to load\n * @param timeoutMs Optional timeout override for all entries\n * @returns This instance for chaining\n */\n load(entries: Iterable<[K, V]>, timeoutMs?: number): this {\n for (const [key, value] of entries) {\n this.set(key, value, timeoutMs)\n }\n return this\n }\n\n /**\n * Updates an existing value or creates a new one using an update function.\n *\n * @param key The key to update\n * @param update Function that receives the current value and returns the new value\n * @returns This instance for chaining\n */\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this {\n return this.set(key, update(this.get(key), key, this))\n }\n\n /**\n * Gets a value or creates it using a factory function if it doesn't exist.\n * Refreshes timeout if the value exists.\n *\n * @param key The key to get or create\n * @param factory Function to create the value if it doesn't exist\n * @param timeoutMs Optional timeout override for new entries\n * @returns The existing or newly created value\n */\n getOrDefault(key: K, factory: (key: K, map: this) => V, timeoutMs?: number): V {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (vt) {\n const [value, timeout] = vt\n timeout.refresh()\n return value\n } else {\n const value = factory(key, this)\n this.set(key, value, timeoutMs)\n return value\n }\n }\n}\n","import { ExtMap } from './ExtMap'\nimport { MultiSet } from 'mnemonist'\nimport { reduce } from 'iter-tools'\n\n/**\n * Count unique occurrences of values in an iterable, returning a sorted map by count descending.\n */\nexport function countUniques<V>(input: Iterable<V>) {\n return new ExtMap<V, number>(\n reduce(\n new MultiSet<V>(), //\n (acc, imp) => acc.add(imp),\n input\n ).multiplicities()\n ).sortByValues((a, b) => b - a)\n}\n","/**\n * Checks if the provided value implements the Map interface with the specified required properties.\n */\nexport function isGenericMap<Props extends (keyof Map<K, V>)[], K, V>(\n target: unknown,\n requiredProps: Props = ['get', 'set', 'has'] as unknown as Props\n): target is Pick<Map<K, V>, Props[number]> {\n return !!target && requiredProps.every((prop) => typeof (target as never)[prop] === typeof Map.prototype[prop])\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../object/src/defineMethod.ts","../../../object/src/entriesOf.ts","../../../composition/src/View.ts","../../../composition/src/inheritProxifiedPrototypeProperty.ts","../../../composition/src/inheritProxifiedPrototype.ts","../../src/entriesArray.ts","../../../iter/src/filterIterableValues.ts","../../../iter/src/mapIterableKeys.ts","../../../iter/src/mapIterableValues.ts","../../../iter/src/reduceIterableValues.ts","../../../iter/src/toObjectIterable.ts","../../src/keysArray.ts","../../src/mapGetOrDefault.ts","../../src/mapLoad.ts","../../src/mapReverse.ts","../../src/mapUpdate.ts","../../src/sort.ts","../../src/sortByKeys.ts","../../src/sortByValues.ts","../../../fn/src/setNameAndLength.ts","../../../fn/src/thisify.ts","../../../fn/src/transformReturnValue.ts","../../src/toMap.ts","../../src/valuesArray.ts","../../src/ExtMap.ts","../../src/TimeoutWeakMap.ts","../../src/countUniques.ts","../../src/isGenericMap.ts"],"names":["defineMethod","obj","key","value","des","Object","defineProperty","configurable","writable","enumerable","entriesOf","entries","TARGET_SYMBOL","View","target","Symbol","toStringTag","name","inheritProxifiedPrototypeProperty","ViewerClass","TargetClass","Reflect","getOwnPropertyDescriptor","prototype","args","get","set","undefined","inheritProxifiedPrototype","omitKeys","ownKeys","filter","k","includes","forEach","entriesArray","ins","Array","from","filterIterableValues","mapLike","predicate","v","mapIterableKeys","mapper","map","mapIterableValues","reduceIterableValues","reducer","initial","accumulator","toObjectIterable","object","String","keysArray","keys","mapGetOrDefault","factory","has","mapLoad","mapReverse","reverse","clear","mapUpdate","update","newValue","sort","compare","sortByKeys","a","b","sortByValues","setNameAndLength","source","lengthDelta","defineProperties","length","thisify","fn","f","transformReturnValue","transform","result","apply","toMap","Map","valuesArray","values","ExtMap","arg","isIterable","fromObject","fromIterable","clone","toJSON","inspect","custom","_depth","_options","breakLength","TimeoutWeakMap","wmap","WeakMap","timeoutMs","vt","timeout","refresh","setTimeout","delete","unref","clearTimeout","load","getOrDefault","countUniques","input","reduce","MultiSet","acc","imp","add","multiplicities","isGenericMap","requiredProps","every","prop"],"mappings":";;;;;;;;;;AAMO,SAASA,aACdC,GAAAA,EACAC,GAAAA,EACAC,KAAAA,EACAC,GAAAA,GAAkD,EAAC,EAAC;AAEpD,EAAA,OAAOC,MAAAA,CAAOC,cAAAA,CAAkBL,GAAAA,EAAKC,GAAAA,EAAK;AACxCC,IAAAA,KAAAA;IACAI,YAAAA,EAAc,IAAA;IACdC,QAAAA,EAAU,IAAA;IACVC,UAAAA,EAAY,KAAA;IACZ,GAAGL;GACL,CAAA;AACF;AAbgBJ,MAA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O,SAAS8G,aAAgBC,KAAAA,EAAkB;AAChD,EAAA,OAAO,IAAI1B,OACT2B,gBAAAA,CACE,IAAIC,oBAAAA,EACJ,CAACC,GAAAA,EAAKC,GAAAA,KAAQD,GAAAA,CAAIE,GAAAA,CAAID,GAAAA,CAAAA,EACtBJ,KAAAA,CAAAA,CACAM,cAAAA,EAAc,CAAA,CAChBjD,aAAa,CAACF,CAAAA,EAAGC,CAAAA,KAAMA,CAAAA,GAAID,CAAAA,CAAAA;AAC/B;AARgB4C,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;;;ACJT,SAASQ,YAAAA,CACd3G,QACA4G,aAAAA,GAAuB;AAAC,EAAA,KAAA;AAAO,EAAA,KAAA;AAAO,EAAA;AAA0B,CAAA,EAAA;AAEhE,EAAA,OAAO,CAAC,CAAC5G,MAAAA,IAAU4G,aAAAA,CAAcC,MAAM,CAACC,IAAAA,KAAS,OAAQ9G,MAAAA,CAAiB8G,IAAAA,CAAAA,KAAU,OAAOvC,GAAAA,CAAI9D,SAAAA,CAAUqG,IAAAA,CAAK,CAAA;AAChH;AALgBH,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"index.cjs","sourcesContent":["import type { AccessorDescriptor } from './isAccessorDescriptor'\nimport type { ValueDescriptor } from './isValueDescriptor'\n\n/**\n * Define a method property on an object with enhanced descriptor handling.\n */\nexport function defineMethod<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n value: V,\n des: ValueDescriptor<T> | AccessorDescriptor<T> = {}\n) {\n return Object.defineProperty<T>(obj, key, {\n value,\n configurable: true,\n writable: true,\n enumerable: false,\n ...des,\n })\n}\n","import type { StringKeyOf } from '@mono/types'\n\n/**\n * Same as Object.entries except the keys are typed as keyof T.\n */\nexport function entriesOf<T extends object>(obj: T): [StringKeyOf<T>, T[StringKeyOf<T>]][] {\n return Object.entries(obj) as [StringKeyOf<T>, T[StringKeyOf<T>]][]\n}\n","import type { IView } from './IView'\n\nconst TARGET_SYMBOL = Symbol('target')\n\n/**\n * Base class providing view functionality over a target object using the Composition pattern.\n */\nexport class View<Target extends object> implements IView<Target> {\n private [TARGET_SYMBOL]: Target\n\n constructor(target: Target) {\n this[TARGET_SYMBOL] = target\n }\n\n get [Symbol.toStringTag](): string {\n return this.constructor.name\n }\n\n get target(): Target {\n return this[TARGET_SYMBOL]\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\n\n/**\n * Inherits a single prototype property from a target class to a viewer class with proxification.\n */\nexport function inheritProxifiedPrototypeProperty<Viewer extends IView<Target>, Target extends object>(\n ViewerClass: Class<Viewer>,\n TargetClass: Class<Target>,\n key: keyof Target\n) {\n const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key)\n if (!des) {\n return\n }\n\n if (des.value && typeof des.value === 'function') {\n return Object.defineProperty(ViewerClass.prototype, key, {\n value(...args: any[]) {\n return this.target[key](...args)\n },\n writable: true,\n configurable: true,\n enumerable: false,\n })\n } else if (des && !des.get && !des.set) {\n return Object.defineProperty(ViewerClass.prototype, key, {\n get(this: Viewer) {\n return this.target[key]\n },\n set: des.writable\n ? function set(this: Viewer, value: Target[keyof Target]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n } else {\n Object.defineProperty(ViewerClass.prototype, key, {\n get: des.get\n ? function (this: Viewer) {\n return this.target[key]\n }\n : undefined,\n set: des.set\n ? function (this: Viewer, value: Target[typeof key]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\nimport { inheritProxifiedPrototypeProperty } from './inheritProxifiedPrototypeProperty'\n\n/**\n * Inherits prototype properties from a target class to a viewer class with proxification, excluding specified keys.\n */\nexport function inheritProxifiedPrototype<\n Viewer extends IView<Target>,\n Target extends object,\n Omitted extends PropertyKey[] = [],\n>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, omitKeys: Omitted) {\n Reflect.ownKeys(TargetClass.prototype)\n .filter((k) => k !== 'constructor' && k !== Symbol.toStringTag)\n .filter((k) => (omitKeys ? !omitKeys.includes(k) : true))\n .forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k as keyof Target))\n return ViewerClass as typeof ViewerClass & { prototype: Viewer & Omit<Target, Omitted[number]> }\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all key-value pairs in the map.\n * Convenience method that converts the entries iterator to an array.\n *\n * @returns Array of all key-value pairs\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function entriesArray<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): [K, V][] {\n return Array.from(ins)\n}\n","import { filter } from 'iter-tools'\n\n/**\n * Filter an iterable of key-value entries based on a predicate function that tests values.\n *\n * @param mapLike - An iterable of key-value tuples to filter\n * @param predicate - A function that tests each value. Returns `true` to keep the entry, `false` otherwise.\n * @returns An iterable containing only the entries whose values satisfy the predicate\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const filtered = filterIterableValues(entries, (value) => value > 1)\n * // filtered: Iterable of [['b', 2], ['c', 3]]\n * ```\n */\nexport function filterIterableValues<K, V, V2 extends V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => value is V2\n): Iterable<[K, V2]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]> {\n return filter(([k, v]: [K, V]) => predicate(v, k), mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the keys in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each key\n * @returns An iterable containing entries with transformed keys\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableKeys(entries, (key) => key.toUpperCase())\n * // mapped: Iterable of [['A', 1], ['B', 2], ['C', 3]]\n * ```\n */\nexport function mapIterableKeys<K, V, K2>(\n mapLike: Iterable<[K, V]>,\n mapper: (key: K, value: V) => K2\n): Iterable<[K2, V]> {\n return map(([k, v]: [K, V]) => [mapper(k, v), v] as [K2, V], mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the values in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each value\n * @returns An iterable containing entries with transformed values\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableValues(entries, (value) => value * 2)\n * // mapped: Iterable of [['a', 2], ['b', 4], ['c', 6]]\n * ```\n */\nexport function mapIterableValues<K, V, V2>(\n mapLike: Iterable<[K, V]>,\n mapper: (value: V, key: K) => V2\n): Iterable<[K, V2]> {\n return map(([k, v]: [K, V]) => [k, mapper(v, k)] as [K, V2], mapLike)\n}\n","/**\n * Reduce an iterable of key-value entries based on values using a reducer function.\n *\n * @param mapLike - An iterable of key-value tuples to reduce\n * @param reducer - A function that combines values\n * @param initial - The initial value for the reduction\n * @returns The reduced value\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const sum = reduceIterableValues(entries, (acc, value, key) => acc + value, 0)\n * // sum: 6\n * ```\n */\nexport function reduceIterableValues<K, V, R>(\n mapLike: Iterable<[K, V]>,\n reducer: (accumulator: R, value: V, key: K) => R,\n initial: R\n): R {\n let accumulator = initial\n for (const [k, v] of mapLike) {\n accumulator = reducer(accumulator, v, k)\n }\n return accumulator\n}\n","/**\n * Convert a map-like iterable to a regular object.\n */\nexport function toObjectIterable<K extends string, V>(mapLike: Iterable<[K, V]>): Record<K, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>): Record<Extract<K, string> | string, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>) {\n const object = {} as Record<PropertyKey, V>\n for (const [key, value] of mapLike) {\n if (typeof key === 'string' || typeof key === 'number' || typeof key === 'symbol') {\n object[key] = value\n } else {\n object[String(key)] = value\n }\n }\n return object\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all keys in the map.\n * Convenience method that converts the keys iterator to an array.\n *\n * @returns Array of all keys\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(keysArray(map)) // ['a', 'b', 'c']\n * ```\n */\nexport function keysArray<K, V>(ins: GenericMap<K, V, 'keys'>): K[] {\n return Array.from(ins.keys())\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Gets a value from a map or creates it using a factory function if it doesn't exist.\n */\nexport function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(\n map: T,\n key: K,\n factory: (key: K, map: T) => V\n): V {\n let value = map.get(key)\n if (value !== undefined || map.has(key)) {\n return value as V\n }\n value = factory(key, map)\n map.set(key, value)\n return value\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Loads multiple entries into the map from an iterable.\n *\n * @param entries - An iterable of key-value pairs to load into the map\n * @returns The map instance for method chaining\n */\nexport function mapLoad<T extends GenericMap<K, V, 'set'>, K, V>(ins: T, entries: Iterable<[K, V]>): T {\n for (const [key, value] of entries) {\n ins.set(key, value)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\nimport { mapLoad } from './mapLoad'\n\n/**\n * Reverses the order of entries in a Map.\n * @remarks This function creates a new Map with the entries of the original Map in reverse order.\n * The original Map is not modified.\n * @example ```ts\n * mapReverse(new Map([['a', 1], ['b', 2], ['c', 3]]));\n * //=> [['c', 3], ['b', 2], ['a', 1]]\n * ```\n */\nexport function mapReverse<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T): T\nexport function mapReverse<K, V>(ins: Map<K, V>): Map<K, V>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapReverse<K, V>(ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>): any {\n const entries = Array.from(ins).reverse()\n ins.clear()\n mapLoad(ins, entries)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Updates a value in the map using an update function.\n *\n * @param key - The key to update\n * @param update - Function that receives the current value and returns the new value\n * @returns The map instance for method chaining\n */\nexport function mapUpdate<T extends GenericMap<K, V, 'set' | 'get'>, K, V>(\n ins: T,\n key: K,\n update: (value: V | undefined, key: K, map: T) => V\n): T\nexport function mapUpdate<K, V>(\n ins: Map<K, V>,\n key: K,\n update: (value: V | undefined, key: K, map: Map<K, V>) => V\n): typeof ins\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapUpdate<K, V>(ins: any, key: K, update: (value: V | undefined, key: K, map: any) => V) {\n const newValue = update(ins.get(key), key, ins)\n\n ins.set(key, newValue)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries using a custom comparison function and updates the map in place.\n * This is Map-specific because it maintains insertion order.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two entries\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sort(map, ([k1], [k2]) => k1.localeCompare(k2))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sort<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: [K, V], b: [K, V]) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort(compare)\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their keys and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two keys\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByKeys(map, (a, b) => a.localeCompare(b))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByKeys<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: K, b: K) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort((a, b) => compare(a[0], b[0]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their values and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two values\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByValues(map, (a, b) => a - b)\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByValues<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(\n ins: T,\n compare: (a: V, b: V) => number\n): T\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n const entries = Array.from(ins).sort((a, b) => compare(a[1], b[1]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { Any } from '@mono/types'\n\n/**\n * Preserves the name and length of a function or class constructor\n */\nexport function setNameAndLength<\n S extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n F extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n>(source: S, target: F, lengthDelta = 0): F {\n return Object.defineProperties(target, {\n name: { configurable: true, value: source.name }, //\n length: { configurable: true, value: source.length + lengthDelta },\n })\n}\n","import type { Any } from '@mono/types'\nimport type { ArraySlice } from 'type-fest'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Converts a function to a class method by making the 'this' context the first argument.\n */\nexport function thisify<T, Args extends Any[], Ret>(\n fn: (target: T, ...args: Args) => Ret\n): (this: T, ...args: Args) => Ret {\n return setNameAndLength(\n fn,\n function f(this: T, ...args: Args): Ret {\n return fn(this, ...args)\n },\n -1\n )\n}\n\nexport type Thisify<T extends object, F extends (target: T, ...args: any[]) => Any> = (\n this: T,\n ...args: ArraySlice<Parameters<F>, 1>\n) => ReturnType<F>\n","import { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wraps a function to transform its return value using a transform function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function transformReturnValue<T, Args extends any[], Ret, NewRet>(\n fn: (this: T, ...args: Args) => Ret,\n transform: (value: Ret) => NewRet\n): (this: T, ...args: Args) => NewRet {\n return setNameAndLength(fn, function (this: T, ...args: Args): NewRet {\n const result = fn.apply(this, args)\n return transform(result)\n })\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Converts a GenericMap to a native Map.\n *\n * @param ins - The GenericMap instance to convert\n * @returns A new native Map with the same entries\n *\n * @example\n * ```typescript\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * const nativeMap = toMap(extMap)\n * console.log(nativeMap instanceof Map) // true\n * ```\n */\nexport function toMap<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): Map<K, V> {\n return new Map(ins)\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all values in the map.\n * Convenience method that converts the values iterator to an array.\n *\n * @returns Array of all values\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(valuesArray(map)) // [1, 2, 3]\n * ```\n */\nexport function valuesArray<K, V>(ins: GenericMap<K, V, 'values'>): V[] {\n return Array.from(ins.values())\n}\n","import type { InspectOptions } from 'util'\nimport { View } from '@mono/composition'\nimport { defineMethod } from '@mono/object'\nimport { entriesArray } from './entriesArray'\nimport { entriesOf } from '@mono/object'\nimport { filterIterableValues } from '@mono/iter'\nimport { inheritProxifiedPrototype } from '@mono/composition'\nimport { inspect } from 'util'\nimport { isIterable } from 'iter-tools'\nimport { keysArray } from './keysArray'\nimport { mapGetOrDefault } from './mapGetOrDefault'\nimport { mapIterableKeys } from '@mono/iter'\nimport { mapIterableValues } from '@mono/iter'\nimport { mapLoad } from './mapLoad'\nimport { mapReverse } from './mapReverse'\nimport { mapUpdate } from './mapUpdate'\nimport { reduceIterableValues } from '@mono/iter'\nimport { sort } from './sort'\nimport { sortByKeys } from './sortByKeys'\nimport { sortByValues } from './sortByValues'\nimport { thisify } from '@mono/fn'\nimport { toMap } from './toMap'\nimport { toObjectIterable } from '@mono/iter'\nimport { transformReturnValue } from '@mono/fn'\nimport { valuesArray } from './valuesArray'\n\ndeclare module './ExtMap' {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export interface ExtMap<K = any, V = any> extends Map<K, V> {\n load(entries: Iterable<[K, V]>): this\n sort(compare: (a: [K, V], b: [K, V]) => number): this\n sortByKeys(compare: (a: K, b: K) => number): this\n sortByValues(compare: (a: V, b: V) => number): this\n reverse(): this\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this\n getOrDefault(key: K, factory: (key: K, map: this) => V): V\n keysArray(): K[]\n valuesArray(): V[]\n entriesArray(): [K, V][]\n toMap(): Map<K, V>\n toObject<K extends string, V>(): Record<K, V>\n toObject<K, V>(): Record<Extract<K, PropertyKey> | string, V>\n reduce<R>(reducer: (accumulator: R, value: V, key: K) => R, initialValue: R): R\n map<NewK, NewV>(mapper: (value: V, key: K) => [NewK, NewV]): ExtMap<NewK, NewV>\n mapKeys<NewK>(mapper: (key: K, value: V) => NewK): ExtMap<NewK, V>\n mapValues<NewV>(mapper: (value: V, key: K) => NewV): ExtMap<K, NewV>\n filter(predicate: (value: V, key: K) => boolean): ExtMap<K, V>\n }\n}\n\n/**\n * Minimal Extended Map class focused only on Map-specific utilities.\n *\n * @template K - The type of keys in the map\n * @template V - The type of values in the map\n *\n * @example\n * ```typescript\n * import { map as iterMap, filter } from 'iter-tools'\n *\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n * .update('a', v => (v ?? 0) + 10)\n * .sortByValues((a, b) => a - b)\n *\n * // Use iter-tools for transformations\n * const doubled = new ExtMap<string, number>()\n * .load(iterMap(([k, v]) => [k, v * 2], extMap))\n *\n * // Use iter-tools for filtering\n * const filtered = new ExtMap<string, number>()\n * .load(filter(([k, v]) => v > 5, extMap))\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ExtMap<K = any, V = any> extends View<Map<K, V>> implements Map<K, V> {\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined)\n constructor(obj?: Record<Extract<K, PropertyKey>, V>)\n constructor(arg?: Record<Extract<K, PropertyKey>, V> | Iterable<readonly [K, V]> | null | undefined) {\n super(new Map(isIterable(arg) ? arg : arg ? entriesOf(arg) : undefined))\n }\n\n /**\n * Creates a new ExtMap instance from a regular object.\n *\n * @param obj - An object whose key-value pairs will be used to initialize the map\n * @returns A new ExtMap instance containing the entries from the object\n */\n static fromObject<K extends PropertyKey, V>(obj: Record<K, V>): ExtMap<K, V> {\n return new ExtMap(Object.entries(obj)) as ExtMap<K, V>\n }\n\n /**\n * Creates a new ExtMap instance from an iterable of key-value pairs.\n *\n * @param entries - An iterable of key-value pairs to initialize the map\n * @returns A new ExtMap instance containing the provided entries\n */\n static fromIterable<K, V>(entries: Iterable<readonly [K, V]>): ExtMap<K, V> {\n return new ExtMap(entries)\n }\n\n /**\n * Creates a shallow copy of the map.\n *\n * @returns A new ExtMap instance with the same entries\n */\n clone(): ExtMap<K, V> {\n return new ExtMap(this)\n }\n\n /**\n * Converts the map to a JSON-serializable format.\n *\n * @returns Array of key-value pairs suitable for JSON serialization\n */\n toJSON(): [K, V][] {\n return [...this.entries()]\n }\n\n /**\n * Custom inspection method for better debugging output.\n *\n * @param _depth - The depth of inspection\n * @param _options - Options for inspection\n * @returns A string representation of the map\n */\n [inspect.custom](_depth: number, _options: InspectOptions): string {\n return inspect(this.target, { breakLength: 50 })\n }\n}\n\ninheritProxifiedPrototype(ExtMap, Map, [])\n\ndefineMethod(ExtMap.prototype, 'load', thisify(mapLoad))\ndefineMethod(ExtMap.prototype, 'sort', thisify(sort))\ndefineMethod(ExtMap.prototype, 'sortByKeys', thisify(sortByKeys))\ndefineMethod(ExtMap.prototype, 'sortByValues', thisify(sortByValues))\ndefineMethod(ExtMap.prototype, 'reverse', thisify(mapReverse))\ndefineMethod(ExtMap.prototype, 'update', thisify(mapUpdate))\ndefineMethod(ExtMap.prototype, 'getOrDefault', thisify(mapGetOrDefault))\ndefineMethod(ExtMap.prototype, 'keysArray', thisify(keysArray))\ndefineMethod(ExtMap.prototype, 'valuesArray', thisify(valuesArray))\ndefineMethod(ExtMap.prototype, 'entriesArray', thisify(entriesArray))\ndefineMethod(ExtMap.prototype, 'toObject', thisify(toObjectIterable))\ndefineMethod(ExtMap.prototype, 'toMap', thisify(toMap))\ndefineMethod(ExtMap.prototype, 'reduce', thisify(reduceIterableValues))\ndefineMethod(ExtMap.prototype, 'map', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapKeys', thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapValues', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'filter', thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)))\n","/**\n * A WeakMap with automatic timeout-based expiry for entries.\n *\n * Entries are automatically removed after a specified timeout period.\n * Accessing an entry refreshes its timeout, extending its lifetime.\n * This is useful for caching scenarios where you want automatic cleanup\n * of unused entries while keeping frequently accessed ones alive.\n */\nexport class TimeoutWeakMap<K extends object, V> {\n protected readonly wmap = new WeakMap<K, [V, NodeJS.Timeout]>()\n\n /**\n * @param timeoutMs Default timeout in milliseconds for entries\n */\n constructor(readonly timeoutMs: number) {}\n\n /**\n * Retrieves the value for the given key and refreshes its timeout.\n *\n * @param key The key to retrieve\n * @returns The value if found, undefined otherwise\n */\n get(key: K): V | undefined {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return undefined\n }\n const [value, timeout] = vt\n timeout.refresh()\n return value\n }\n\n /**\n * Sets a key-value pair with an optional custom timeout.\n *\n * @param key The key to set\n * @param value The value to associate with the key\n * @param timeoutMs Optional timeout override for this entry\n * @returns This instance for chaining\n */\n set(key: K, value: V, timeoutMs?: number): this {\n this.wmap.set(key, [\n value,\n setTimeout(() => {\n this.delete(key)\n }, timeoutMs ?? this.timeoutMs).unref(),\n ])\n return this\n }\n\n /**\n * Removes a key-value pair and clears its timeout.\n *\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: K): boolean {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return false\n }\n const timeout = vt[1]\n clearTimeout(timeout)\n return this.wmap.delete(key)\n }\n\n /**\n * Checks if a key exists in the map.\n * Does not refresh the timeout.\n *\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: K): boolean {\n return this.wmap.has(key)\n }\n\n /**\n * Loads multiple key-value pairs into the map.\n *\n * @param entries Iterable of key-value pairs to load\n * @param timeoutMs Optional timeout override for all entries\n * @returns This instance for chaining\n */\n load(entries: Iterable<[K, V]>, timeoutMs?: number): this {\n for (const [key, value] of entries) {\n this.set(key, value, timeoutMs)\n }\n return this\n }\n\n /**\n * Updates an existing value or creates a new one using an update function.\n *\n * @param key The key to update\n * @param update Function that receives the current value and returns the new value\n * @returns This instance for chaining\n */\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this {\n return this.set(key, update(this.get(key), key, this))\n }\n\n /**\n * Gets a value or creates it using a factory function if it doesn't exist.\n * Refreshes timeout if the value exists.\n *\n * @param key The key to get or create\n * @param factory Function to create the value if it doesn't exist\n * @param timeoutMs Optional timeout override for new entries\n * @returns The existing or newly created value\n */\n getOrDefault(key: K, factory: (key: K, map: this) => V, timeoutMs?: number): V {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (vt) {\n const [value, timeout] = vt\n timeout.refresh()\n return value\n } else {\n const value = factory(key, this)\n this.set(key, value, timeoutMs)\n return value\n }\n }\n}\n","import { ExtMap } from './ExtMap'\nimport { MultiSet } from 'mnemonist'\nimport { reduce } from 'iter-tools'\n\n/**\n * Count unique occurrences of values in an iterable, returning a sorted map by count descending.\n */\nexport function countUniques<V>(input: Iterable<V>) {\n return new ExtMap<V, number>(\n reduce(\n new MultiSet<V>(), //\n (acc, imp) => acc.add(imp),\n input\n ).multiplicities()\n ).sortByValues((a, b) => b - a)\n}\n","/**\n * Checks if the provided value implements the Map interface with the specified required properties.\n */\nexport function isGenericMap<Props extends (keyof Map<K, V>)[], K, V>(\n target: unknown,\n requiredProps: Props = ['get', 'set', 'has'] as unknown as Props\n): target is Pick<Map<K, V>, Props[number]> {\n return !!target && requiredProps.every((prop) => typeof (target as never)[prop] === typeof Map.prototype[prop])\n}\n"]}
|
package/lib/index.js
CHANGED
|
@@ -127,10 +127,10 @@ __name(reduceIterableValues, "reduceIterableValues");
|
|
|
127
127
|
function toObjectIterable(mapLike) {
|
|
128
128
|
const object = {};
|
|
129
129
|
for (const [key, value] of mapLike) {
|
|
130
|
-
if (typeof key
|
|
131
|
-
object[String(key)] = value;
|
|
132
|
-
} else {
|
|
130
|
+
if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
133
131
|
object[key] = value;
|
|
132
|
+
} else {
|
|
133
|
+
object[String(key)] = value;
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
return object;
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../object/src/defineMethod.ts","../../../object/src/entriesOf.ts","../../../composition/src/View.ts","../../../composition/src/inheritProxifiedPrototypeProperty.ts","../../../composition/src/inheritProxifiedPrototype.ts","../../src/entriesArray.ts","../../../iter/src/filterIterableValues.ts","../../../iter/src/mapIterableKeys.ts","../../../iter/src/mapIterableValues.ts","../../../iter/src/reduceIterableValues.ts","../../../iter/src/toObjectIterable.ts","../../src/keysArray.ts","../../src/mapGetOrDefault.ts","../../src/mapLoad.ts","../../src/mapReverse.ts","../../src/mapUpdate.ts","../../src/sort.ts","../../src/sortByKeys.ts","../../src/sortByValues.ts","../../../fn/src/setNameAndLength.ts","../../../fn/src/thisify.ts","../../../fn/src/transformReturnValue.ts","../../src/toMap.ts","../../src/valuesArray.ts","../../src/ExtMap.ts","../../src/TimeoutWeakMap.ts","../../src/countUniques.ts","../../src/isGenericMap.ts"],"names":["defineMethod","obj","key","value","des","Object","defineProperty","configurable","writable","enumerable","entriesOf","entries","TARGET_SYMBOL","View","target","Symbol","toStringTag","name","inheritProxifiedPrototypeProperty","ViewerClass","TargetClass","Reflect","getOwnPropertyDescriptor","prototype","args","get","set","undefined","inheritProxifiedPrototype","omitKeys","ownKeys","filter","k","includes","forEach","entriesArray","ins","Array","from","filterIterableValues","mapLike","predicate","v","mapIterableKeys","mapper","map","mapIterableValues","reduceIterableValues","reducer","initial","accumulator","toObjectIterable","object","String","keysArray","keys","mapGetOrDefault","factory","has","mapLoad","mapReverse","reverse","clear","mapUpdate","update","newValue","sort","compare","sortByKeys","a","b","sortByValues","setNameAndLength","source","lengthDelta","defineProperties","length","thisify","fn","f","transformReturnValue","transform","result","apply","toMap","Map","valuesArray","values","ExtMap","arg","isIterable","fromObject","fromIterable","clone","toJSON","inspect","custom","_depth","_options","breakLength","TimeoutWeakMap","wmap","WeakMap","timeoutMs","vt","timeout","refresh","setTimeout","delete","unref","clearTimeout","load","getOrDefault","countUniques","input","reduce","MultiSet","acc","imp","add","multiplicities","isGenericMap","requiredProps","every","prop"],"mappings":";;;;;;;;AAMO,SAASA,aACdC,GAAAA,EACAC,GAAAA,EACAC,KAAAA,EACAC,GAAAA,GAAkD,EAAC,EAAC;AAEpD,EAAA,OAAOC,MAAAA,CAAOC,cAAAA,CAAkBL,GAAAA,EAAKC,GAAAA,EAAK;AACxCC,IAAAA,KAAAA;IACAI,YAAAA,EAAc,IAAA;IACdC,QAAAA,EAAU,IAAA;IACVC,UAAAA,EAAY,KAAA;IACZ,GAAGL;GACL,CAAA;AACF;AAbgBJ,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;;;ACDT,SAASU,UAA4BT,GAAAA,EAAM;AAChD,EAAA,OAAOI,MAAAA,CAAOM,QAAQV,GAAAA,CAAAA;AACxB;AAFgBS,MAAAA,CAAAA,SAAAA,EAAAA,WAAAA,CAAAA;;;ACHhB,IAAME,aAAAA,0BAAuB,QAAA,CAAA;AAKtB,IAAMC,OAAN,MAAMA;EALb;;;AAMU,EAAA,CAACD,aAAAA;AAET,EAAA,WAAA,CAAYE,MAAAA,EAAgB;AAC1B,IAAA,IAAA,CAAKF,aAAAA,CAAAA,GAAiBE,MAAAA;AACxB,EAAA;EAEA,KAAKC,MAAAA,CAAOC,WAAW,CAAA,GAAY;AACjC,IAAA,OAAO,KAAK,WAAA,CAAYC,IAAAA;AAC1B,EAAA;AAEA,EAAA,IAAIH,MAAAA,GAAiB;AACnB,IAAA,OAAO,KAAKF,a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AS,OAAQ9G,MAAAA,CAAiB8G,IAAAA,CAAAA,KAAU,OAAOvC,GAAAA,CAAI9D,SAAAA,CAAUqG,IAAAA,CAAK,CAAA;AAChH;AALgBH,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"index.js","sourcesContent":["import type { AccessorDescriptor } from './isAccessorDescriptor'\nimport type { ValueDescriptor } from './isValueDescriptor'\n\n/**\n * Define a method property on an object with enhanced descriptor handling.\n */\nexport function defineMethod<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n value: V,\n des: ValueDescriptor<T> | AccessorDescriptor<T> = {}\n) {\n return Object.defineProperty<T>(obj, key, {\n value,\n configurable: true,\n writable: true,\n enumerable: false,\n ...des,\n })\n}\n","import type { StringKeyOf } from '@mono/types'\n\n/**\n * Same as Object.entries except the keys are typed as keyof T.\n */\nexport function entriesOf<T extends object>(obj: T): [StringKeyOf<T>, T[StringKeyOf<T>]][] {\n return Object.entries(obj) as [StringKeyOf<T>, T[StringKeyOf<T>]][]\n}\n","import type { IView } from './IView'\n\nconst TARGET_SYMBOL = Symbol('target')\n\n/**\n * Base class providing view functionality over a target object using the Composition pattern.\n */\nexport class View<Target extends object> implements IView<Target> {\n private [TARGET_SYMBOL]: Target\n\n constructor(target: Target) {\n this[TARGET_SYMBOL] = target\n }\n\n get [Symbol.toStringTag](): string {\n return this.constructor.name\n }\n\n get target(): Target {\n return this[TARGET_SYMBOL]\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\n\n/**\n * Inherits a single prototype property from a target class to a viewer class with proxification.\n */\nexport function inheritProxifiedPrototypeProperty<Viewer extends IView<Target>, Target extends object>(\n ViewerClass: Class<Viewer>,\n TargetClass: Class<Target>,\n key: keyof Target\n) {\n const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key)\n if (!des) {\n return\n }\n\n if (des.value && typeof des.value === 'function') {\n return Object.defineProperty(ViewerClass.prototype, key, {\n value(...args: any[]) {\n return this.target[key](...args)\n },\n writable: true,\n configurable: true,\n enumerable: false,\n })\n } else if (des && !des.get && !des.set) {\n return Object.defineProperty(ViewerClass.prototype, key, {\n get(this: Viewer) {\n return this.target[key]\n },\n set: des.writable\n ? function set(this: Viewer, value: Target[keyof Target]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n } else {\n Object.defineProperty(ViewerClass.prototype, key, {\n get: des.get\n ? function (this: Viewer) {\n return this.target[key]\n }\n : undefined,\n set: des.set\n ? function (this: Viewer, value: Target[typeof key]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\nimport { inheritProxifiedPrototypeProperty } from './inheritProxifiedPrototypeProperty'\n\n/**\n * Inherits prototype properties from a target class to a viewer class with proxification, excluding specified keys.\n */\nexport function inheritProxifiedPrototype<\n Viewer extends IView<Target>,\n Target extends object,\n Omitted extends PropertyKey[] = [],\n>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, omitKeys: Omitted) {\n Reflect.ownKeys(TargetClass.prototype)\n .filter((k) => k !== 'constructor' && k !== Symbol.toStringTag)\n .filter((k) => (omitKeys ? !omitKeys.includes(k) : true))\n .forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k as keyof Target))\n return ViewerClass as typeof ViewerClass & { prototype: Viewer & Omit<Target, Omitted[number]> }\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all key-value pairs in the map.\n * Convenience method that converts the entries iterator to an array.\n *\n * @returns Array of all key-value pairs\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function entriesArray<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): [K, V][] {\n return Array.from(ins)\n}\n","import { filter } from 'iter-tools'\n\n/**\n * Filter an iterable of key-value entries based on a predicate function that tests values.\n *\n * @param mapLike - An iterable of key-value tuples to filter\n * @param predicate - A function that tests each value. Returns `true` to keep the entry, `false` otherwise.\n * @returns An iterable containing only the entries whose values satisfy the predicate\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const filtered = filterIterableValues(entries, (value) => value > 1)\n * // filtered: Iterable of [['b', 2], ['c', 3]]\n * ```\n */\nexport function filterIterableValues<K, V, V2 extends V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => value is V2\n): Iterable<[K, V2]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]> {\n return filter(([k, v]: [K, V]) => predicate(v, k), mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the keys in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each key\n * @returns An iterable containing entries with transformed keys\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableKeys(entries, (key) => key.toUpperCase())\n * // mapped: Iterable of [['A', 1], ['B', 2], ['C', 3]]\n * ```\n */\nexport function mapIterableKeys<K, V, K2>(\n mapLike: Iterable<[K, V]>,\n mapper: (key: K, value: V) => K2\n): Iterable<[K2, V]> {\n return map(([k, v]: [K, V]) => [mapper(k, v), v] as [K2, V], mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the values in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each value\n * @returns An iterable containing entries with transformed values\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableValues(entries, (value) => value * 2)\n * // mapped: Iterable of [['a', 2], ['b', 4], ['c', 6]]\n * ```\n */\nexport function mapIterableValues<K, V, V2>(\n mapLike: Iterable<[K, V]>,\n mapper: (value: V, key: K) => V2\n): Iterable<[K, V2]> {\n return map(([k, v]: [K, V]) => [k, mapper(v, k)] as [K, V2], mapLike)\n}\n","/**\n * Reduce an iterable of key-value entries based on values using a reducer function.\n *\n * @param mapLike - An iterable of key-value tuples to reduce\n * @param reducer - A function that combines values\n * @param initial - The initial value for the reduction\n * @returns The reduced value\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const sum = reduceIterableValues(entries, (acc, value, key) => acc + value, 0)\n * // sum: 6\n * ```\n */\nexport function reduceIterableValues<K, V, R>(\n mapLike: Iterable<[K, V]>,\n reducer: (accumulator: R, value: V, key: K) => R,\n initial: R\n): R {\n let accumulator = initial\n for (const [k, v] of mapLike) {\n accumulator = reducer(accumulator, v, k)\n }\n return accumulator\n}\n","/**\n * Convert a map-like iterable to a regular object.\n */\nexport function toObjectIterable<K extends string, V>(mapLike: Iterable<[K, V]>): Record<K, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>): Record<Extract<K, string> | string, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>) {\n const object = {} as Record<PropertyKey, V>\n for (const [key, value] of mapLike) {\n if (typeof key !== 'string' && typeof key !== 'number' && typeof key !== 'symbol') {\n object[String(key)] = value\n } else {\n object[key] = value\n }\n }\n return object\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all keys in the map.\n * Convenience method that converts the keys iterator to an array.\n *\n * @returns Array of all keys\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(keysArray(map)) // ['a', 'b', 'c']\n * ```\n */\nexport function keysArray<K, V>(ins: GenericMap<K, V, 'keys'>): K[] {\n return Array.from(ins.keys())\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Gets a value from a map or creates it using a factory function if it doesn't exist.\n */\nexport function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(\n map: T,\n key: K,\n factory: (key: K, map: T) => V\n): V {\n let value = map.get(key)\n if (value !== undefined || map.has(key)) {\n return value as V\n }\n value = factory(key, map)\n map.set(key, value)\n return value\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Loads multiple entries into the map from an iterable.\n *\n * @param entries - An iterable of key-value pairs to load into the map\n * @returns The map instance for method chaining\n */\nexport function mapLoad<T extends GenericMap<K, V, 'set'>, K, V>(ins: T, entries: Iterable<[K, V]>): T {\n for (const [key, value] of entries) {\n ins.set(key, value)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\nimport { mapLoad } from './mapLoad'\n\n/**\n * Reverses the order of entries in a Map.\n * @remarks This function creates a new Map with the entries of the original Map in reverse order.\n * The original Map is not modified.\n * @example ```ts\n * mapReverse(new Map([['a', 1], ['b', 2], ['c', 3]]));\n * //=> [['c', 3], ['b', 2], ['a', 1]]\n * ```\n */\nexport function mapReverse<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T): T\nexport function mapReverse<K, V>(ins: Map<K, V>): Map<K, V>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapReverse<K, V>(ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>): any {\n const entries = Array.from(ins).reverse()\n ins.clear()\n mapLoad(ins, entries)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Updates a value in the map using an update function.\n *\n * @param key - The key to update\n * @param update - Function that receives the current value and returns the new value\n * @returns The map instance for method chaining\n */\nexport function mapUpdate<T extends GenericMap<K, V, 'set' | 'get'>, K, V>(\n ins: T,\n key: K,\n update: (value: V | undefined, key: K, map: T) => V\n): T\nexport function mapUpdate<K, V>(\n ins: Map<K, V>,\n key: K,\n update: (value: V | undefined, key: K, map: Map<K, V>) => V\n): typeof ins\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapUpdate<K, V>(ins: any, key: K, update: (value: V | undefined, key: K, map: any) => V) {\n const newValue = update(ins.get(key), key, ins)\n\n ins.set(key, newValue)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries using a custom comparison function and updates the map in place.\n * This is Map-specific because it maintains insertion order.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two entries\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sort(map, ([k1], [k2]) => k1.localeCompare(k2))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sort<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: [K, V], b: [K, V]) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort(compare)\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their keys and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two keys\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByKeys(map, (a, b) => a.localeCompare(b))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByKeys<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: K, b: K) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort((a, b) => compare(a[0], b[0]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their values and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two values\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByValues(map, (a, b) => a - b)\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByValues<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(\n ins: T,\n compare: (a: V, b: V) => number\n): T\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n const entries = Array.from(ins).sort((a, b) => compare(a[1], b[1]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { Any } from '@mono/types'\n\n/**\n * Preserves the name and length of a function or class constructor\n */\nexport function setNameAndLength<\n S extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n F extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n>(source: S, target: F, lengthDelta = 0): F {\n return Object.defineProperties(target, {\n name: { configurable: true, value: source.name }, //\n length: { configurable: true, value: source.length + lengthDelta },\n })\n}\n","import type { Any } from '@mono/types'\nimport type { ArraySlice } from 'type-fest'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Converts a function to a class method by making the 'this' context the first argument.\n */\nexport function thisify<T, Args extends Any[], Ret>(\n fn: (target: T, ...args: Args) => Ret\n): (this: T, ...args: Args) => Ret {\n return setNameAndLength(\n fn,\n function f(this: T, ...args: Args): Ret {\n return fn(this, ...args)\n },\n -1\n )\n}\n\nexport type Thisify<T extends object, F extends (target: T, ...args: any[]) => Any> = (\n this: T,\n ...args: ArraySlice<Parameters<F>, 1>\n) => ReturnType<F>\n","import { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wraps a function to transform its return value using a transform function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function transformReturnValue<T, Args extends any[], Ret, NewRet>(\n fn: (this: T, ...args: Args) => Ret,\n transform: (value: Ret) => NewRet\n): (this: T, ...args: Args) => NewRet {\n return setNameAndLength(fn, function (this: T, ...args: Args): NewRet {\n const result = fn.apply(this, args)\n return transform(result)\n })\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Converts a GenericMap to a native Map.\n *\n * @param ins - The GenericMap instance to convert\n * @returns A new native Map with the same entries\n *\n * @example\n * ```typescript\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * const nativeMap = toMap(extMap)\n * console.log(nativeMap instanceof Map) // true\n * ```\n */\nexport function toMap<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): Map<K, V> {\n return new Map(ins)\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all values in the map.\n * Convenience method that converts the values iterator to an array.\n *\n * @returns Array of all values\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(valuesArray(map)) // [1, 2, 3]\n * ```\n */\nexport function valuesArray<K, V>(ins: GenericMap<K, V, 'values'>): V[] {\n return Array.from(ins.values())\n}\n","import type { InspectOptions } from 'util'\nimport { View } from '@mono/composition'\nimport { defineMethod } from '@mono/object'\nimport { entriesArray } from './entriesArray'\nimport { entriesOf } from '@mono/object'\nimport { filterIterableValues } from '@mono/iter'\nimport { inheritProxifiedPrototype } from '@mono/composition'\nimport { inspect } from 'util'\nimport { isIterable } from 'iter-tools'\nimport { keysArray } from './keysArray'\nimport { mapGetOrDefault } from './mapGetOrDefault'\nimport { mapIterableKeys } from '@mono/iter'\nimport { mapIterableValues } from '@mono/iter'\nimport { mapLoad } from './mapLoad'\nimport { mapReverse } from './mapReverse'\nimport { mapUpdate } from './mapUpdate'\nimport { reduceIterableValues } from '@mono/iter'\nimport { sort } from './sort'\nimport { sortByKeys } from './sortByKeys'\nimport { sortByValues } from './sortByValues'\nimport { thisify } from '@mono/fn'\nimport { toMap } from './toMap'\nimport { toObjectIterable } from '@mono/iter'\nimport { transformReturnValue } from '@mono/fn'\nimport { valuesArray } from './valuesArray'\n\ndeclare module './ExtMap' {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export interface ExtMap<K = any, V = any> extends Map<K, V> {\n load(entries: Iterable<[K, V]>): this\n sort(compare: (a: [K, V], b: [K, V]) => number): this\n sortByKeys(compare: (a: K, b: K) => number): this\n sortByValues(compare: (a: V, b: V) => number): this\n reverse(): this\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this\n getOrDefault(key: K, factory: (key: K, map: this) => V): V\n keysArray(): K[]\n valuesArray(): V[]\n entriesArray(): [K, V][]\n toMap(): Map<K, V>\n toObject<K extends string, V>(): Record<K, V>\n toObject<K, V>(): Record<Extract<K, PropertyKey> | string, V>\n reduce<R>(reducer: (accumulator: R, value: V, key: K) => R, initialValue: R): R\n map<NewK, NewV>(mapper: (value: V, key: K) => [NewK, NewV]): ExtMap<NewK, NewV>\n mapKeys<NewK>(mapper: (key: K, value: V) => NewK): ExtMap<NewK, V>\n mapValues<NewV>(mapper: (value: V, key: K) => NewV): ExtMap<K, NewV>\n filter(predicate: (value: V, key: K) => boolean): ExtMap<K, V>\n }\n}\n\n/**\n * Minimal Extended Map class focused only on Map-specific utilities.\n *\n * @template K - The type of keys in the map\n * @template V - The type of values in the map\n *\n * @example\n * ```typescript\n * import { map as iterMap, filter } from 'iter-tools'\n *\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n * .update('a', v => (v ?? 0) + 10)\n * .sortByValues((a, b) => a - b)\n *\n * // Use iter-tools for transformations\n * const doubled = new ExtMap<string, number>()\n * .load(iterMap(([k, v]) => [k, v * 2], extMap))\n *\n * // Use iter-tools for filtering\n * const filtered = new ExtMap<string, number>()\n * .load(filter(([k, v]) => v > 5, extMap))\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ExtMap<K = any, V = any> extends View<Map<K, V>> implements Map<K, V> {\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined)\n constructor(obj?: Record<Extract<K, PropertyKey>, V>)\n constructor(arg?: Record<Extract<K, PropertyKey>, V> | Iterable<readonly [K, V]> | null | undefined) {\n super(new Map(isIterable(arg) ? arg : arg ? entriesOf(arg) : undefined))\n }\n\n /**\n * Creates a new ExtMap instance from a regular object.\n *\n * @param obj - An object whose key-value pairs will be used to initialize the map\n * @returns A new ExtMap instance containing the entries from the object\n */\n static fromObject<K extends PropertyKey, V>(obj: Record<K, V>): ExtMap<K, V> {\n return new ExtMap(Object.entries(obj)) as ExtMap<K, V>\n }\n\n /**\n * Creates a new ExtMap instance from an iterable of key-value pairs.\n *\n * @param entries - An iterable of key-value pairs to initialize the map\n * @returns A new ExtMap instance containing the provided entries\n */\n static fromIterable<K, V>(entries: Iterable<readonly [K, V]>): ExtMap<K, V> {\n return new ExtMap(entries)\n }\n\n /**\n * Creates a shallow copy of the map.\n *\n * @returns A new ExtMap instance with the same entries\n */\n clone(): ExtMap<K, V> {\n return new ExtMap(this)\n }\n\n /**\n * Converts the map to a JSON-serializable format.\n *\n * @returns Array of key-value pairs suitable for JSON serialization\n */\n toJSON(): [K, V][] {\n return [...this.entries()]\n }\n\n /**\n * Custom inspection method for better debugging output.\n *\n * @param _depth - The depth of inspection\n * @param _options - Options for inspection\n * @returns A string representation of the map\n */\n [inspect.custom](_depth: number, _options: InspectOptions): string {\n return inspect(this.target, { breakLength: 50 })\n }\n}\n\ninheritProxifiedPrototype(ExtMap, Map, [])\n\ndefineMethod(ExtMap.prototype, 'load', thisify(mapLoad))\ndefineMethod(ExtMap.prototype, 'sort', thisify(sort))\ndefineMethod(ExtMap.prototype, 'sortByKeys', thisify(sortByKeys))\ndefineMethod(ExtMap.prototype, 'sortByValues', thisify(sortByValues))\ndefineMethod(ExtMap.prototype, 'reverse', thisify(mapReverse))\ndefineMethod(ExtMap.prototype, 'update', thisify(mapUpdate))\ndefineMethod(ExtMap.prototype, 'getOrDefault', thisify(mapGetOrDefault))\ndefineMethod(ExtMap.prototype, 'keysArray', thisify(keysArray))\ndefineMethod(ExtMap.prototype, 'valuesArray', thisify(valuesArray))\ndefineMethod(ExtMap.prototype, 'entriesArray', thisify(entriesArray))\ndefineMethod(ExtMap.prototype, 'toObject', thisify(toObjectIterable))\ndefineMethod(ExtMap.prototype, 'toMap', thisify(toMap))\ndefineMethod(ExtMap.prototype, 'reduce', thisify(reduceIterableValues))\ndefineMethod(ExtMap.prototype, 'map', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapKeys', thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapValues', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'filter', thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)))\n","/**\n * A WeakMap with automatic timeout-based expiry for entries.\n *\n * Entries are automatically removed after a specified timeout period.\n * Accessing an entry refreshes its timeout, extending its lifetime.\n * This is useful for caching scenarios where you want automatic cleanup\n * of unused entries while keeping frequently accessed ones alive.\n */\nexport class TimeoutWeakMap<K extends object, V> {\n protected readonly wmap = new WeakMap<K, [V, NodeJS.Timeout]>()\n\n /**\n * @param timeoutMs Default timeout in milliseconds for entries\n */\n constructor(readonly timeoutMs: number) {}\n\n /**\n * Retrieves the value for the given key and refreshes its timeout.\n *\n * @param key The key to retrieve\n * @returns The value if found, undefined otherwise\n */\n get(key: K): V | undefined {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return undefined\n }\n const [value, timeout] = vt\n timeout.refresh()\n return value\n }\n\n /**\n * Sets a key-value pair with an optional custom timeout.\n *\n * @param key The key to set\n * @param value The value to associate with the key\n * @param timeoutMs Optional timeout override for this entry\n * @returns This instance for chaining\n */\n set(key: K, value: V, timeoutMs?: number): this {\n this.wmap.set(key, [\n value,\n setTimeout(() => {\n this.delete(key)\n }, timeoutMs ?? this.timeoutMs).unref(),\n ])\n return this\n }\n\n /**\n * Removes a key-value pair and clears its timeout.\n *\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: K): boolean {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return false\n }\n const timeout = vt[1]\n clearTimeout(timeout)\n return this.wmap.delete(key)\n }\n\n /**\n * Checks if a key exists in the map.\n * Does not refresh the timeout.\n *\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: K): boolean {\n return this.wmap.has(key)\n }\n\n /**\n * Loads multiple key-value pairs into the map.\n *\n * @param entries Iterable of key-value pairs to load\n * @param timeoutMs Optional timeout override for all entries\n * @returns This instance for chaining\n */\n load(entries: Iterable<[K, V]>, timeoutMs?: number): this {\n for (const [key, value] of entries) {\n this.set(key, value, timeoutMs)\n }\n return this\n }\n\n /**\n * Updates an existing value or creates a new one using an update function.\n *\n * @param key The key to update\n * @param update Function that receives the current value and returns the new value\n * @returns This instance for chaining\n */\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this {\n return this.set(key, update(this.get(key), key, this))\n }\n\n /**\n * Gets a value or creates it using a factory function if it doesn't exist.\n * Refreshes timeout if the value exists.\n *\n * @param key The key to get or create\n * @param factory Function to create the value if it doesn't exist\n * @param timeoutMs Optional timeout override for new entries\n * @returns The existing or newly created value\n */\n getOrDefault(key: K, factory: (key: K, map: this) => V, timeoutMs?: number): V {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (vt) {\n const [value, timeout] = vt\n timeout.refresh()\n return value\n } else {\n const value = factory(key, this)\n this.set(key, value, timeoutMs)\n return value\n }\n }\n}\n","import { ExtMap } from './ExtMap'\nimport { MultiSet } from 'mnemonist'\nimport { reduce } from 'iter-tools'\n\n/**\n * Count unique occurrences of values in an iterable, returning a sorted map by count descending.\n */\nexport function countUniques<V>(input: Iterable<V>) {\n return new ExtMap<V, number>(\n reduce(\n new MultiSet<V>(), //\n (acc, imp) => acc.add(imp),\n input\n ).multiplicities()\n ).sortByValues((a, b) => b - a)\n}\n","/**\n * Checks if the provided value implements the Map interface with the specified required properties.\n */\nexport function isGenericMap<Props extends (keyof Map<K, V>)[], K, V>(\n target: unknown,\n requiredProps: Props = ['get', 'set', 'has'] as unknown as Props\n): target is Pick<Map<K, V>, Props[number]> {\n return !!target && requiredProps.every((prop) => typeof (target as never)[prop] === typeof Map.prototype[prop])\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../object/src/defineMethod.ts","../../../object/src/entriesOf.ts","../../../composition/src/View.ts","../../../composition/src/inheritProxifiedPrototypeProperty.ts","../../../composition/src/inheritProxifiedPrototype.ts","../../src/entriesArray.ts","../../../iter/src/filterIterableValues.ts","../../../iter/src/mapIterableKeys.ts","../../../iter/src/mapIterableValues.ts","../../../iter/src/reduceIterableValues.ts","../../../iter/src/toObjectIterable.ts","../../src/keysArray.ts","../../src/mapGetOrDefault.ts","../../src/mapLoad.ts","../../src/mapReverse.ts","../../src/mapUpdate.ts","../../src/sort.ts","../../src/sortByKeys.ts","../../src/sortByValues.ts","../../../fn/src/setNameAndLength.ts","../../../fn/src/thisify.ts","../../../fn/src/transformReturnValue.ts","../../src/toMap.ts","../../src/valuesArray.ts","../../src/ExtMap.ts","../../src/TimeoutWeakMap.ts","../../src/countUniques.ts","../../src/isGenericMap.ts"],"names":["defineMethod","obj","key","value","des","Object","defineProperty","configurable","writable","enumerable","entriesOf","entries","TARGET_SYMBOL","View","target","Symbol","toStringTag","name","inheritProxifiedPrototypeProperty","ViewerClass","TargetClass","Reflect","getOwnPropertyDescriptor","prototype","args","get","set","undefined","inheritProxifiedPrototype","omitKeys","ownKeys","filter","k","includes","forEach","entriesArray","ins","Array","from","filterIterableValues","mapLike","predicate","v","mapIterableKeys","mapper","map","mapIterableValues","reduceIterableValues","reducer","initial","accumulator","toObjectIterable","object","String","keysArray","keys","mapGetOrDefault","factory","has","mapLoad","mapReverse","reverse","clear","mapUpdate","update","newValue","sort","compare","sortByKeys","a","b","sortByValues","setNameAndLength","source","lengthDelta","defineProperties","length","thisify","fn","f","transformReturnValue","transform","result","apply","toMap","Map","valuesArray","values","ExtMap","arg","isIterable","fromObject","fromIterable","clone","toJSON","inspect","custom","_depth","_options","breakLength","TimeoutWeakMap","wmap","WeakMap","timeoutMs","vt","timeout","refresh","setTimeout","delete","unref","clearTimeout","load","getOrDefault","countUniques","input","reduce","MultiSet","acc","imp","add","multiplicities","isGenericMap","requiredProps","every","prop"],"mappings":";;;;;;;;AAMO,SAASA,aACdC,GAAAA,EACAC,GAAAA,EACAC,KAAAA,EACAC,GAAAA,GAAkD,EAAC,EAAC;AAEpD,EAAA,OAAOC,MAAAA,CAAOC,cAAAA,CAAkBL,GAAAA,EAAKC,GAAAA,EAAK;AACxCC,IAAAA,KAAAA;IACAI,YAAAA,EAAc,IAAA;IACdC,QAAAA,EAAU,IAAA;IACVC,UAAAA,EAAY,KAAA;IACZ,GAAGL;GACL,CAAA;AACF;AAbgBJ,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;;;ACDT,SAASU,UAA4BT,GAAAA,EAAM;AAChD,EAAA,OAAOI,MAAAA,CAAOM,QAAQV,GAAAA,CAAAA;AACxB;AAFgBS,MAAAA,CAAAA,SAAAA,EAAAA,WAAAA,CAAAA;;;ACHhB,IAAME,aAAAA,0BAAuB,QAAA,CAAA;AAKtB,IAAMC,OAAN,MAAMA;EALb;;;AAMU,EAAA,CAACD,aAAAA;AAET,EAAA,WAAA,CAAYE,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AAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA;;;ACJT,SAASQ,YAAAA,CACd3G,QACA4G,aAAAA,GAAuB;AAAC,EAAA,KAAA;AAAO,EAAA,KAAA;AAAO,EAAA;AAA0B,CAAA,EAAA;AAEhE,EAAA,OAAO,CAAC,CAAC5G,MAAAA,IAAU4G,aAAAA,CAAcC,MAAM,CAACC,IAAAA,KAAS,OAAQ9G,MAAAA,CAAiB8G,IAAAA,CAAAA,KAAU,OAAOvC,GAAAA,CAAI9D,SAAAA,CAAUqG,IAAAA,CAAK,CAAA;AAChH;AALgBH,MAAAA,CAAAA,YAAAA,EAAAA,cAAAA,CAAAA","file":"index.js","sourcesContent":["import type { AccessorDescriptor } from './isAccessorDescriptor'\nimport type { ValueDescriptor } from './isValueDescriptor'\n\n/**\n * Define a method property on an object with enhanced descriptor handling.\n */\nexport function defineMethod<T extends object, V = object>(\n obj: T,\n key: PropertyKey,\n value: V,\n des: ValueDescriptor<T> | AccessorDescriptor<T> = {}\n) {\n return Object.defineProperty<T>(obj, key, {\n value,\n configurable: true,\n writable: true,\n enumerable: false,\n ...des,\n })\n}\n","import type { StringKeyOf } from '@mono/types'\n\n/**\n * Same as Object.entries except the keys are typed as keyof T.\n */\nexport function entriesOf<T extends object>(obj: T): [StringKeyOf<T>, T[StringKeyOf<T>]][] {\n return Object.entries(obj) as [StringKeyOf<T>, T[StringKeyOf<T>]][]\n}\n","import type { IView } from './IView'\n\nconst TARGET_SYMBOL = Symbol('target')\n\n/**\n * Base class providing view functionality over a target object using the Composition pattern.\n */\nexport class View<Target extends object> implements IView<Target> {\n private [TARGET_SYMBOL]: Target\n\n constructor(target: Target) {\n this[TARGET_SYMBOL] = target\n }\n\n get [Symbol.toStringTag](): string {\n return this.constructor.name\n }\n\n get target(): Target {\n return this[TARGET_SYMBOL]\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\n\n/**\n * Inherits a single prototype property from a target class to a viewer class with proxification.\n */\nexport function inheritProxifiedPrototypeProperty<Viewer extends IView<Target>, Target extends object>(\n ViewerClass: Class<Viewer>,\n TargetClass: Class<Target>,\n key: keyof Target\n) {\n const des = Reflect.getOwnPropertyDescriptor(TargetClass.prototype, key)\n if (!des) {\n return\n }\n\n if (des.value && typeof des.value === 'function') {\n return Object.defineProperty(ViewerClass.prototype, key, {\n value(...args: any[]) {\n return this.target[key](...args)\n },\n writable: true,\n configurable: true,\n enumerable: false,\n })\n } else if (des && !des.get && !des.set) {\n return Object.defineProperty(ViewerClass.prototype, key, {\n get(this: Viewer) {\n return this.target[key]\n },\n set: des.writable\n ? function set(this: Viewer, value: Target[keyof Target]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n } else {\n Object.defineProperty(ViewerClass.prototype, key, {\n get: des.get\n ? function (this: Viewer) {\n return this.target[key]\n }\n : undefined,\n set: des.set\n ? function (this: Viewer, value: Target[typeof key]) {\n this.target[key] = value\n }\n : undefined,\n configurable: true,\n enumerable: false,\n })\n }\n}\n","import type { Class } from 'type-fest'\nimport type { IView } from './IView'\nimport { inheritProxifiedPrototypeProperty } from './inheritProxifiedPrototypeProperty'\n\n/**\n * Inherits prototype properties from a target class to a viewer class with proxification, excluding specified keys.\n */\nexport function inheritProxifiedPrototype<\n Viewer extends IView<Target>,\n Target extends object,\n Omitted extends PropertyKey[] = [],\n>(ViewerClass: Class<Viewer>, TargetClass: Class<Target>, omitKeys: Omitted) {\n Reflect.ownKeys(TargetClass.prototype)\n .filter((k) => k !== 'constructor' && k !== Symbol.toStringTag)\n .filter((k) => (omitKeys ? !omitKeys.includes(k) : true))\n .forEach((k) => inheritProxifiedPrototypeProperty(ViewerClass, TargetClass, k as keyof Target))\n return ViewerClass as typeof ViewerClass & { prototype: Viewer & Omit<Target, Omitted[number]> }\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all key-value pairs in the map.\n * Convenience method that converts the entries iterator to an array.\n *\n * @returns Array of all key-value pairs\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function entriesArray<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): [K, V][] {\n return Array.from(ins)\n}\n","import { filter } from 'iter-tools'\n\n/**\n * Filter an iterable of key-value entries based on a predicate function that tests values.\n *\n * @param mapLike - An iterable of key-value tuples to filter\n * @param predicate - A function that tests each value. Returns `true` to keep the entry, `false` otherwise.\n * @returns An iterable containing only the entries whose values satisfy the predicate\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const filtered = filterIterableValues(entries, (value) => value > 1)\n * // filtered: Iterable of [['b', 2], ['c', 3]]\n * ```\n */\nexport function filterIterableValues<K, V, V2 extends V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => value is V2\n): Iterable<[K, V2]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]>\nexport function filterIterableValues<K, V>(\n mapLike: Iterable<[K, V]>,\n predicate: (value: V, key: K) => boolean\n): Iterable<[K, V]> {\n return filter(([k, v]: [K, V]) => predicate(v, k), mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the keys in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each key\n * @returns An iterable containing entries with transformed keys\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableKeys(entries, (key) => key.toUpperCase())\n * // mapped: Iterable of [['A', 1], ['B', 2], ['C', 3]]\n * ```\n */\nexport function mapIterableKeys<K, V, K2>(\n mapLike: Iterable<[K, V]>,\n mapper: (key: K, value: V) => K2\n): Iterable<[K2, V]> {\n return map(([k, v]: [K, V]) => [mapper(k, v), v] as [K2, V], mapLike)\n}\n","import { map } from 'iter-tools'\n\n/**\n * Transform the values in an iterable of key-value pairs using a mapper function.\n *\n * @param mapLike - An iterable of key-value tuples to transform\n * @param mapper - A function that transforms each value\n * @returns An iterable containing entries with transformed values\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const mapped = mapIterableValues(entries, (value) => value * 2)\n * // mapped: Iterable of [['a', 2], ['b', 4], ['c', 6]]\n * ```\n */\nexport function mapIterableValues<K, V, V2>(\n mapLike: Iterable<[K, V]>,\n mapper: (value: V, key: K) => V2\n): Iterable<[K, V2]> {\n return map(([k, v]: [K, V]) => [k, mapper(v, k)] as [K, V2], mapLike)\n}\n","/**\n * Reduce an iterable of key-value entries based on values using a reducer function.\n *\n * @param mapLike - An iterable of key-value tuples to reduce\n * @param reducer - A function that combines values\n * @param initial - The initial value for the reduction\n * @returns The reduced value\n *\n * @example\n * ```ts\n * const entries: [string, number][] = [['a', 1], ['b', 2], ['c', 3]]\n * const sum = reduceIterableValues(entries, (acc, value, key) => acc + value, 0)\n * // sum: 6\n * ```\n */\nexport function reduceIterableValues<K, V, R>(\n mapLike: Iterable<[K, V]>,\n reducer: (accumulator: R, value: V, key: K) => R,\n initial: R\n): R {\n let accumulator = initial\n for (const [k, v] of mapLike) {\n accumulator = reducer(accumulator, v, k)\n }\n return accumulator\n}\n","/**\n * Convert a map-like iterable to a regular object.\n */\nexport function toObjectIterable<K extends string, V>(mapLike: Iterable<[K, V]>): Record<K, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>): Record<Extract<K, string> | string, V>\nexport function toObjectIterable<K, V>(mapLike: Iterable<[K, V]>) {\n const object = {} as Record<PropertyKey, V>\n for (const [key, value] of mapLike) {\n if (typeof key === 'string' || typeof key === 'number' || typeof key === 'symbol') {\n object[key] = value\n } else {\n object[String(key)] = value\n }\n }\n return object\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all keys in the map.\n * Convenience method that converts the keys iterator to an array.\n *\n * @returns Array of all keys\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(keysArray(map)) // ['a', 'b', 'c']\n * ```\n */\nexport function keysArray<K, V>(ins: GenericMap<K, V, 'keys'>): K[] {\n return Array.from(ins.keys())\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Gets a value from a map or creates it using a factory function if it doesn't exist.\n */\nexport function mapGetOrDefault<K, V, T extends GenericMap<K, V, 'get' | 'has' | 'set'>>(\n map: T,\n key: K,\n factory: (key: K, map: T) => V\n): V {\n let value = map.get(key)\n if (value !== undefined || map.has(key)) {\n return value as V\n }\n value = factory(key, map)\n map.set(key, value)\n return value\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Loads multiple entries into the map from an iterable.\n *\n * @param entries - An iterable of key-value pairs to load into the map\n * @returns The map instance for method chaining\n */\nexport function mapLoad<T extends GenericMap<K, V, 'set'>, K, V>(ins: T, entries: Iterable<[K, V]>): T {\n for (const [key, value] of entries) {\n ins.set(key, value)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\nimport { mapLoad } from './mapLoad'\n\n/**\n * Reverses the order of entries in a Map.\n * @remarks This function creates a new Map with the entries of the original Map in reverse order.\n * The original Map is not modified.\n * @example ```ts\n * mapReverse(new Map([['a', 1], ['b', 2], ['c', 3]]));\n * //=> [['c', 3], ['b', 2], ['a', 1]]\n * ```\n */\nexport function mapReverse<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(ins: T): T\nexport function mapReverse<K, V>(ins: Map<K, V>): Map<K, V>\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapReverse<K, V>(ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>): any {\n const entries = Array.from(ins).reverse()\n ins.clear()\n mapLoad(ins, entries)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Updates a value in the map using an update function.\n *\n * @param key - The key to update\n * @param update - Function that receives the current value and returns the new value\n * @returns The map instance for method chaining\n */\nexport function mapUpdate<T extends GenericMap<K, V, 'set' | 'get'>, K, V>(\n ins: T,\n key: K,\n update: (value: V | undefined, key: K, map: T) => V\n): T\nexport function mapUpdate<K, V>(\n ins: Map<K, V>,\n key: K,\n update: (value: V | undefined, key: K, map: Map<K, V>) => V\n): typeof ins\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function mapUpdate<K, V>(ins: any, key: K, update: (value: V | undefined, key: K, map: any) => V) {\n const newValue = update(ins.get(key), key, ins)\n\n ins.set(key, newValue)\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries using a custom comparison function and updates the map in place.\n * This is Map-specific because it maintains insertion order.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two entries\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sort(map, ([k1], [k2]) => k1.localeCompare(k2))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sort<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: [K, V], b: [K, V]) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort(compare)\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their keys and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two keys\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByKeys(map, (a, b) => a.localeCompare(b))\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByKeys<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: K, b: K) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator> {\n const entries = Array.from(ins).sort((a, b) => compare(a[0], b[0]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Sorts the map entries by their values and updates the map in place.\n *\n * @param ins - The map instance to sort\n * @param compare - Function that compares two values\n * @returns The map instance for method chaining\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>([\n * ['c', 3],\n * ['a', 1],\n * ['b', 2],\n * ])\n *\n * sortByValues(map, (a, b) => a - b)\n * console.log(entriesArray(map)) // [['a', 1], ['b', 2], ['c', 3]]\n * ```\n */\nexport function sortByValues<T extends GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>, K, V>(\n ins: T,\n compare: (a: V, b: V) => number\n): T\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n): GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>\nexport function sortByValues<K, V>(\n ins: GenericMap<K, V, 'set' | 'clear' | typeof Symbol.iterator>,\n compare: (a: V, b: V) => number\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n): any {\n const entries = Array.from(ins).sort((a, b) => compare(a[1], b[1]))\n ins.clear()\n for (const [k, v] of entries) {\n ins.set(k, v)\n }\n return ins\n}\n","import type { Any } from '@mono/types'\n\n/**\n * Preserves the name and length of a function or class constructor\n */\nexport function setNameAndLength<\n S extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n F extends ((...args: Any[]) => Any) | (new (...args: Any[]) => Any),\n>(source: S, target: F, lengthDelta = 0): F {\n return Object.defineProperties(target, {\n name: { configurable: true, value: source.name }, //\n length: { configurable: true, value: source.length + lengthDelta },\n })\n}\n","import type { Any } from '@mono/types'\nimport type { ArraySlice } from 'type-fest'\nimport { setNameAndLength } from './setNameAndLength'\n\n/**\n * Converts a function to a class method by making the 'this' context the first argument.\n */\nexport function thisify<T, Args extends Any[], Ret>(\n fn: (target: T, ...args: Args) => Ret\n): (this: T, ...args: Args) => Ret {\n return setNameAndLength(\n fn,\n function f(this: T, ...args: Args): Ret {\n return fn(this, ...args)\n },\n -1\n )\n}\n\nexport type Thisify<T extends object, F extends (target: T, ...args: any[]) => Any> = (\n this: T,\n ...args: ArraySlice<Parameters<F>, 1>\n) => ReturnType<F>\n","import { setNameAndLength } from './setNameAndLength'\n\n/**\n * Wraps a function to transform its return value using a transform function.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function transformReturnValue<T, Args extends any[], Ret, NewRet>(\n fn: (this: T, ...args: Args) => Ret,\n transform: (value: Ret) => NewRet\n): (this: T, ...args: Args) => NewRet {\n return setNameAndLength(fn, function (this: T, ...args: Args): NewRet {\n const result = fn.apply(this, args)\n return transform(result)\n })\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Converts a GenericMap to a native Map.\n *\n * @param ins - The GenericMap instance to convert\n * @returns A new native Map with the same entries\n *\n * @example\n * ```typescript\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * const nativeMap = toMap(extMap)\n * console.log(nativeMap instanceof Map) // true\n * ```\n */\nexport function toMap<K, V>(ins: GenericMap<K, V, typeof Symbol.iterator>): Map<K, V> {\n return new Map(ins)\n}\n","import type { GenericMap } from '@mono/types'\n\n/**\n * Returns an array of all values in the map.\n * Convenience method that converts the values iterator to an array.\n *\n * @returns Array of all values\n *\n * @example\n * ```typescript\n * const map = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n *\n * console.log(valuesArray(map)) // [1, 2, 3]\n * ```\n */\nexport function valuesArray<K, V>(ins: GenericMap<K, V, 'values'>): V[] {\n return Array.from(ins.values())\n}\n","import type { InspectOptions } from 'util'\nimport { View } from '@mono/composition'\nimport { defineMethod } from '@mono/object'\nimport { entriesArray } from './entriesArray'\nimport { entriesOf } from '@mono/object'\nimport { filterIterableValues } from '@mono/iter'\nimport { inheritProxifiedPrototype } from '@mono/composition'\nimport { inspect } from 'util'\nimport { isIterable } from 'iter-tools'\nimport { keysArray } from './keysArray'\nimport { mapGetOrDefault } from './mapGetOrDefault'\nimport { mapIterableKeys } from '@mono/iter'\nimport { mapIterableValues } from '@mono/iter'\nimport { mapLoad } from './mapLoad'\nimport { mapReverse } from './mapReverse'\nimport { mapUpdate } from './mapUpdate'\nimport { reduceIterableValues } from '@mono/iter'\nimport { sort } from './sort'\nimport { sortByKeys } from './sortByKeys'\nimport { sortByValues } from './sortByValues'\nimport { thisify } from '@mono/fn'\nimport { toMap } from './toMap'\nimport { toObjectIterable } from '@mono/iter'\nimport { transformReturnValue } from '@mono/fn'\nimport { valuesArray } from './valuesArray'\n\ndeclare module './ExtMap' {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n export interface ExtMap<K = any, V = any> extends Map<K, V> {\n load(entries: Iterable<[K, V]>): this\n sort(compare: (a: [K, V], b: [K, V]) => number): this\n sortByKeys(compare: (a: K, b: K) => number): this\n sortByValues(compare: (a: V, b: V) => number): this\n reverse(): this\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this\n getOrDefault(key: K, factory: (key: K, map: this) => V): V\n keysArray(): K[]\n valuesArray(): V[]\n entriesArray(): [K, V][]\n toMap(): Map<K, V>\n toObject<K extends string, V>(): Record<K, V>\n toObject<K, V>(): Record<Extract<K, PropertyKey> | string, V>\n reduce<R>(reducer: (accumulator: R, value: V, key: K) => R, initialValue: R): R\n map<NewK, NewV>(mapper: (value: V, key: K) => [NewK, NewV]): ExtMap<NewK, NewV>\n mapKeys<NewK>(mapper: (key: K, value: V) => NewK): ExtMap<NewK, V>\n mapValues<NewV>(mapper: (value: V, key: K) => NewV): ExtMap<K, NewV>\n filter(predicate: (value: V, key: K) => boolean): ExtMap<K, V>\n }\n}\n\n/**\n * Minimal Extended Map class focused only on Map-specific utilities.\n *\n * @template K - The type of keys in the map\n * @template V - The type of values in the map\n *\n * @example\n * ```typescript\n * import { map as iterMap, filter } from 'iter-tools'\n *\n * const extMap = new ExtMap<string, number>()\n * .load([['a', 1], ['b', 2], ['c', 3]])\n * .update('a', v => (v ?? 0) + 10)\n * .sortByValues((a, b) => a - b)\n *\n * // Use iter-tools for transformations\n * const doubled = new ExtMap<string, number>()\n * .load(iterMap(([k, v]) => [k, v * 2], extMap))\n *\n * // Use iter-tools for filtering\n * const filtered = new ExtMap<string, number>()\n * .load(filter(([k, v]) => v > 5, extMap))\n * ```\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class ExtMap<K = any, V = any> extends View<Map<K, V>> implements Map<K, V> {\n constructor(iterable?: Iterable<readonly [K, V]> | null | undefined)\n constructor(obj?: Record<Extract<K, PropertyKey>, V>)\n constructor(arg?: Record<Extract<K, PropertyKey>, V> | Iterable<readonly [K, V]> | null | undefined) {\n super(new Map(isIterable(arg) ? arg : arg ? entriesOf(arg) : undefined))\n }\n\n /**\n * Creates a new ExtMap instance from a regular object.\n *\n * @param obj - An object whose key-value pairs will be used to initialize the map\n * @returns A new ExtMap instance containing the entries from the object\n */\n static fromObject<K extends PropertyKey, V>(obj: Record<K, V>): ExtMap<K, V> {\n return new ExtMap(Object.entries(obj)) as ExtMap<K, V>\n }\n\n /**\n * Creates a new ExtMap instance from an iterable of key-value pairs.\n *\n * @param entries - An iterable of key-value pairs to initialize the map\n * @returns A new ExtMap instance containing the provided entries\n */\n static fromIterable<K, V>(entries: Iterable<readonly [K, V]>): ExtMap<K, V> {\n return new ExtMap(entries)\n }\n\n /**\n * Creates a shallow copy of the map.\n *\n * @returns A new ExtMap instance with the same entries\n */\n clone(): ExtMap<K, V> {\n return new ExtMap(this)\n }\n\n /**\n * Converts the map to a JSON-serializable format.\n *\n * @returns Array of key-value pairs suitable for JSON serialization\n */\n toJSON(): [K, V][] {\n return [...this.entries()]\n }\n\n /**\n * Custom inspection method for better debugging output.\n *\n * @param _depth - The depth of inspection\n * @param _options - Options for inspection\n * @returns A string representation of the map\n */\n [inspect.custom](_depth: number, _options: InspectOptions): string {\n return inspect(this.target, { breakLength: 50 })\n }\n}\n\ninheritProxifiedPrototype(ExtMap, Map, [])\n\ndefineMethod(ExtMap.prototype, 'load', thisify(mapLoad))\ndefineMethod(ExtMap.prototype, 'sort', thisify(sort))\ndefineMethod(ExtMap.prototype, 'sortByKeys', thisify(sortByKeys))\ndefineMethod(ExtMap.prototype, 'sortByValues', thisify(sortByValues))\ndefineMethod(ExtMap.prototype, 'reverse', thisify(mapReverse))\ndefineMethod(ExtMap.prototype, 'update', thisify(mapUpdate))\ndefineMethod(ExtMap.prototype, 'getOrDefault', thisify(mapGetOrDefault))\ndefineMethod(ExtMap.prototype, 'keysArray', thisify(keysArray))\ndefineMethod(ExtMap.prototype, 'valuesArray', thisify(valuesArray))\ndefineMethod(ExtMap.prototype, 'entriesArray', thisify(entriesArray))\ndefineMethod(ExtMap.prototype, 'toObject', thisify(toObjectIterable))\ndefineMethod(ExtMap.prototype, 'toMap', thisify(toMap))\ndefineMethod(ExtMap.prototype, 'reduce', thisify(reduceIterableValues))\ndefineMethod(ExtMap.prototype, 'map', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapKeys', thisify(transformReturnValue(mapIterableKeys, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'mapValues', thisify(transformReturnValue(mapIterableValues, ExtMap.fromIterable)))\ndefineMethod(ExtMap.prototype, 'filter', thisify(transformReturnValue(filterIterableValues, ExtMap.fromIterable)))\n","/**\n * A WeakMap with automatic timeout-based expiry for entries.\n *\n * Entries are automatically removed after a specified timeout period.\n * Accessing an entry refreshes its timeout, extending its lifetime.\n * This is useful for caching scenarios where you want automatic cleanup\n * of unused entries while keeping frequently accessed ones alive.\n */\nexport class TimeoutWeakMap<K extends object, V> {\n protected readonly wmap = new WeakMap<K, [V, NodeJS.Timeout]>()\n\n /**\n * @param timeoutMs Default timeout in milliseconds for entries\n */\n constructor(readonly timeoutMs: number) {}\n\n /**\n * Retrieves the value for the given key and refreshes its timeout.\n *\n * @param key The key to retrieve\n * @returns The value if found, undefined otherwise\n */\n get(key: K): V | undefined {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return undefined\n }\n const [value, timeout] = vt\n timeout.refresh()\n return value\n }\n\n /**\n * Sets a key-value pair with an optional custom timeout.\n *\n * @param key The key to set\n * @param value The value to associate with the key\n * @param timeoutMs Optional timeout override for this entry\n * @returns This instance for chaining\n */\n set(key: K, value: V, timeoutMs?: number): this {\n this.wmap.set(key, [\n value,\n setTimeout(() => {\n this.delete(key)\n }, timeoutMs ?? this.timeoutMs).unref(),\n ])\n return this\n }\n\n /**\n * Removes a key-value pair and clears its timeout.\n *\n * @param key The key to delete\n * @returns True if the key existed and was deleted, false otherwise\n */\n delete(key: K): boolean {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (!vt) {\n return false\n }\n const timeout = vt[1]\n clearTimeout(timeout)\n return this.wmap.delete(key)\n }\n\n /**\n * Checks if a key exists in the map.\n * Does not refresh the timeout.\n *\n * @param key The key to check\n * @returns True if the key exists, false otherwise\n */\n has(key: K): boolean {\n return this.wmap.has(key)\n }\n\n /**\n * Loads multiple key-value pairs into the map.\n *\n * @param entries Iterable of key-value pairs to load\n * @param timeoutMs Optional timeout override for all entries\n * @returns This instance for chaining\n */\n load(entries: Iterable<[K, V]>, timeoutMs?: number): this {\n for (const [key, value] of entries) {\n this.set(key, value, timeoutMs)\n }\n return this\n }\n\n /**\n * Updates an existing value or creates a new one using an update function.\n *\n * @param key The key to update\n * @param update Function that receives the current value and returns the new value\n * @returns This instance for chaining\n */\n update(key: K, update: (value: V | undefined, key: K, map: this) => V): this {\n return this.set(key, update(this.get(key), key, this))\n }\n\n /**\n * Gets a value or creates it using a factory function if it doesn't exist.\n * Refreshes timeout if the value exists.\n *\n * @param key The key to get or create\n * @param factory Function to create the value if it doesn't exist\n * @param timeoutMs Optional timeout override for new entries\n * @returns The existing or newly created value\n */\n getOrDefault(key: K, factory: (key: K, map: this) => V, timeoutMs?: number): V {\n const vt: [V, NodeJS.Timeout] | undefined = this.wmap.get(key)\n if (vt) {\n const [value, timeout] = vt\n timeout.refresh()\n return value\n } else {\n const value = factory(key, this)\n this.set(key, value, timeoutMs)\n return value\n }\n }\n}\n","import { ExtMap } from './ExtMap'\nimport { MultiSet } from 'mnemonist'\nimport { reduce } from 'iter-tools'\n\n/**\n * Count unique occurrences of values in an iterable, returning a sorted map by count descending.\n */\nexport function countUniques<V>(input: Iterable<V>) {\n return new ExtMap<V, number>(\n reduce(\n new MultiSet<V>(), //\n (acc, imp) => acc.add(imp),\n input\n ).multiplicities()\n ).sortByValues((a, b) => b - a)\n}\n","/**\n * Checks if the provided value implements the Map interface with the specified required properties.\n */\nexport function isGenericMap<Props extends (keyof Map<K, V>)[], K, V>(\n target: unknown,\n requiredProps: Props = ['get', 'set', 'has'] as unknown as Props\n): target is Pick<Map<K, V>, Props[number]> {\n return !!target && requiredProps.every((prop) => typeof (target as never)[prop] === typeof Map.prototype[prop])\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bemoje/map",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Extended Map class and utilities for sorting, filtering, mapping, and managing key-value data.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"iter-tools": "^7.5.4",
|
|
12
|
-
"mnemonist": "^0.40.
|
|
12
|
+
"mnemonist": "^0.40.8"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"map",
|