Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@thi.ng/associative

Package Overview
Dependencies
Maintainers
0
Versions
294
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/associative - npm Package Compare versions

Comparing version 6.3.60 to 6.3.61

2

api.d.ts
import type { Comparator, Fn, IClear, ICopy, IEmpty, IEquiv, IGet, IInto, Maybe, Predicate2 } from "@thi.ng/api";
import type { IRandom } from "@thi.ng/random";
export interface IEquivSet<T> extends Set<T>, IClear, ICopy<IEquivSet<T>>, IEmpty<IEquivSet<T>>, IEquiv, IGet<T, T>, IInto<T, IEquivSet<T>> {
disj(xs: Iterable<T>): this;
disj(values: Iterable<T>): this;
first(): Maybe<T>;

@@ -6,0 +6,0 @@ }

@@ -108,10 +108,3 @@ import { isString } from "@thi.ng/checks/is-string";

delete(key) {
const fwd = this.fwd;
const id = fwd.get(key);
if (id !== void 0) {
fwd.delete(key);
this.rev.delete(id);
return true;
}
return false;
return __delete(this.fwd, this.rev, key);
}

@@ -125,10 +118,3 @@ /**

deleteID(id) {
const rev = this.rev;
const k = rev.get(id);
if (k !== void 0) {
rev.delete(id);
this.fwd.delete(k);
return true;
}
return false;
return __delete(this.rev, this.fwd, id);
}

@@ -160,13 +146,3 @@ /**

getAll(keys, fail = false) {
const index = this.fwd;
const res = [];
for (let k of keys) {
const id = index.get(k);
if (id === void 0) {
if (fail) throw new Error(`unknown key: ${k}`);
} else {
res.push(id);
}
}
return res;
return __iterate(this.fwd, keys, fail);
}

@@ -183,13 +159,3 @@ /**

getAllIDs(ids, fail = false) {
const index = this.rev;
const res = [];
for (let id of ids) {
const k = index.get(id);
if (k === void 0) {
if (fail) throw new Error(`unknwon ID: ${id}`);
} else {
res.push(k);
}
}
return res;
return __iterate(this.rev, ids, fail);
}

@@ -208,2 +174,23 @@ /**

}
const __delete = (fwd, rev, key) => {
const val = fwd.get(key);
if (val !== void 0) {
fwd.delete(key);
rev.delete(val);
return true;
}
return false;
};
const __iterate = (index, keys, fail) => {
const res = [];
for (let k of keys) {
const val = index.get(k);
if (val === void 0) {
if (fail) throw new Error(`unknwon key/ID: ${k}`);
} else {
res.push(val);
}
}
return res;
};
const defBidirIndex = (keys, opts) => new BidirIndex(keys, opts);

@@ -210,0 +197,0 @@ const bidirIndexFromJSON = (src, map) => {

# Change Log
- **Last updated**: 2024-05-08T18:24:31Z
- **Last updated**: 2024-06-21T19:34:38Z
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)

@@ -12,2 +12,10 @@

### [6.3.61](https://github.com/thi-ng/umbrella/tree/@thi.ng/associative@6.3.61) (2024-06-21)
#### ♻️ Refactoring
- rename various rest args to be more semantically meaningful ([8088a56](https://github.com/thi-ng/umbrella/commit/8088a56))
- dedupe BidirIndex deletion & iteration, update tests ([3c11a44](https://github.com/thi-ng/umbrella/commit/3c11a44))
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
### [6.3.57](https://github.com/thi-ng/umbrella/tree/@thi.ng/associative@6.3.57) (2024-04-20)

@@ -14,0 +22,0 @@

export declare const copy: (x: any, ctor: Function) => any;
export declare const copyObj: (x: any) => any;
/**
* Creates shallow copy of `src` object without any properties for which
* [`isIllegalKey()`](https://docs.thi.ng/umbrella/checks/functions/isIllegalKey.html)
* returns true.
*
* @param src
*/
export declare const copyObj: (src: any) => any;
//# sourceMappingURL=copy.d.ts.map
import { implementsFunction } from "@thi.ng/checks/implements-function";
import { isIllegalKey } from "@thi.ng/checks/is-proto-path";
const copy = (x, ctor) => implementsFunction(x, "copy") ? x.copy() : new (x[Symbol.species] || ctor)(x);
const copyObj = (x) => {
const copyObj = (src) => {
const res = {};
for (let k in x) {
!isIllegalKey(k) && (res[k] = x[k]);
for (let k in src) {
!isIllegalKey(k) && (res[k] = src[k]);
}

@@ -9,0 +9,0 @@ return res;

@@ -8,4 +8,4 @@ import { mixin } from "@thi.ng/api/mixin";

});
const inspectSet = (coll, opts) => [...map((x) => inspect(x, opts), coll)].join(", ");
const inspectMap = (coll, opts) => [
const __inspectSet = (coll, opts) => [...map((x) => inspect(x, opts), coll)].join(", ");
const __inspectMap = (coll, opts) => [
...map(

@@ -25,3 +25,3 @@ ([k, v]) => `${inspect(k, opts)} => ${inspect(v, opts)}`,

`${name}(${this.size || 0}) {`,
inspect ? this instanceof Set ? inspectSet(this, childOpts) : this instanceof Map ? inspectMap(this, childOpts) : "" : "",
inspect ? this instanceof Set ? __inspectSet(this, childOpts) : this instanceof Map ? __inspectMap(this, childOpts) : "" : "",
"}"

@@ -28,0 +28,0 @@ ].join(" ") : opts.stylize(`[${name}]`, "special");

@@ -66,3 +66,3 @@ /**

*/
export declare const joinWith: <A, B>(a: Set<A>, b: Set<B>, kmap: { [id in keyof A]?: keyof B | undefined; }) => Set<any>;
export declare const joinWith: <A, B>(a: Set<A>, b: Set<B>, kmap: { [id in keyof A]?: keyof B; }) => Set<any>;
//# sourceMappingURL=join.d.ts.map

@@ -6,17 +6,17 @@ import type { Fn, IObjectOf } from "@thi.ng/api";

* @param src - source map
* @param xs - map w/ transformation functions
* @param xforms - map w/ transformation functions
*/
export declare const mergeApplyMap: <K, V>(src: Map<K, V>, xs: Map<K, V | Fn<V, V>>) => Map<K, V>;
export declare const mergeApplyMap: <K, V>(src: Map<K, V>, xforms: Map<K, V | Fn<V, V>>) => Map<K, V>;
/**
* Similar to {@link mergeObjWith}, but only supports 2 args and any
* function values in `xs` will be called with respective value in `src`
* to produce a new / derived value for that key, i.e.
* Similar to {@link mergeObjWith}, but only supports 2 args and any function
* values in `xforms` will be called with respective value in `src` to produce a
* new / derived value for that key, i.e.
*
* @remarks
* Since v4.4.0, the `__proto__` property will be ignored to avoid
* prototype pollution.
* Since v4.4.0, the `__proto__` property will be ignored to avoid prototype
* pollution.
*
* @example
* ```ts
* dest[k] = xs[k](src[k])
* dest[k] = xforms[k](src[k])
* ```

@@ -40,5 +40,5 @@ *

* @param src - source object
* @param xs - object w/ transformation functions
* @param xforms - object w/ transformation functions
*/
export declare const mergeApplyObj: <V>(src: IObjectOf<V>, xs: IObjectOf<V | Fn<V, V>>) => IObjectOf<V>;
export declare const mergeApplyObj: <V>(src: IObjectOf<V>, xforms: IObjectOf<V | Fn<V, V>>) => IObjectOf<V>;
/**

@@ -53,5 +53,5 @@ * Mutable version of {@link mergeApplyObj}. Returns modified `src`

* @param src -
* @param xs -
* @param xforms -
*/
export declare const meldApplyObj: <V>(src: IObjectOf<V>, xs: IObjectOf<V | Fn<V, V>>) => IObjectOf<V>;
export declare const meldApplyObj: <V>(src: IObjectOf<V>, xforms: IObjectOf<V | Fn<V, V>>) => IObjectOf<V>;
//# sourceMappingURL=merge-apply.d.ts.map
import { isFunction } from "@thi.ng/checks/is-function";
import { isIllegalKey } from "@thi.ng/checks/is-proto-path";
import { copy, copyObj } from "./copy.js";
const mergeApplyMap = (src, xs) => {
const mergeApplyMap = (src, xforms) => {
const res = copy(src, Map);
for (let [k, v] of xs) {
for (let [k, v] of xforms) {
res.set(k, isFunction(v) ? v(res.get(k)) : v);

@@ -11,7 +11,7 @@ }

};
const mergeApplyObj = (src, xs) => meldApplyObj(copyObj(src), xs);
const meldApplyObj = (src, xs) => {
for (let k in xs) {
const mergeApplyObj = (src, xforms) => meldApplyObj(copyObj(src), xforms);
const meldApplyObj = (src, xforms) => {
for (let k in xforms) {
if (isIllegalKey(k)) continue;
const v = xs[k];
const v = xforms[k];
src[k] = isFunction(v) ? v(src[k]) : v;

@@ -18,0 +18,0 @@ }

import type { IObjectOf, Nullable } from "@thi.ng/api";
export declare const mergeDeepObj: (dest: IObjectOf<any>, ...xs: Nullable<IObjectOf<any>>[]) => any;
export declare const meldDeepObj: (dest: IObjectOf<any>, ...xs: Nullable<IObjectOf<any>>[]) => any;
export declare const mergeDeepObj: (dest: IObjectOf<any>, ...objects: Nullable<IObjectOf<any>>[]) => any;
export declare const meldDeepObj: (dest: IObjectOf<any>, ...objects: Nullable<IObjectOf<any>>[]) => any;
//# sourceMappingURL=merge-deep.d.ts.map
import { isPlainObject } from "@thi.ng/checks/is-plain-object";
import { meldObjWith, mergeObjWith } from "./merge-with.js";
const mergeDeepObj = (dest, ...xs) => mergeObjWith(
const mergeDeepObj = (dest, ...objects) => mergeObjWith(
(a, b) => isPlainObject(a) && isPlainObject(b) ? mergeDeepObj(a, b) : b,
dest,
...xs
...objects
);
const meldDeepObj = (dest, ...xs) => meldObjWith(
const meldDeepObj = (dest, ...objects) => meldObjWith(
(a, b) => isPlainObject(a) && isPlainObject(b) ? meldDeepObj(a, b) : b,
dest,
...xs
...objects
);

@@ -13,0 +13,0 @@ export {

import type { Fn2, IObjectOf, Nullable } from "@thi.ng/api";
export declare const mergeMapWith: <K, V>(f: Fn2<V, V, V>, dest: Map<K, V>, ...xs: Nullable<Map<K, V>>[]) => Map<K, V>;
export declare const mergeMapWith: <K, V>(f: Fn2<V, V, V>, dest: Map<K, V>, ...maps: Nullable<Map<K, V>>[]) => Map<K, V>;
/**

@@ -14,5 +14,5 @@ * Immutably merges given objects in a pairwise manner. Applies function

* @param dest -
* @param xs -
* @param objects -
*/
export declare const mergeObjWith: <T>(f: Fn2<T, T, T>, dest: IObjectOf<T>, ...xs: Nullable<IObjectOf<T>>[]) => IObjectOf<T>;
export declare const mergeObjWith: <T>(f: Fn2<T, T, T>, dest: IObjectOf<T>, ...objects: Nullable<IObjectOf<T>>[]) => IObjectOf<T>;
/**

@@ -28,5 +28,5 @@ * Mutable version of {@link mergeObjWith}. Returns modified `dest`

* @param dest -
* @param xs -
* @param objects -
*/
export declare const meldObjWith: <T>(f: Fn2<T, T, T>, dest: IObjectOf<T>, ...xs: Nullable<IObjectOf<T>>[]) => IObjectOf<T>;
export declare const meldObjWith: <T>(f: Fn2<T, T, T>, dest: IObjectOf<T>, ...objects: Nullable<IObjectOf<T>>[]) => IObjectOf<T>;
//# sourceMappingURL=merge-with.d.ts.map
import { isIllegalKey } from "@thi.ng/checks/is-proto-path";
import { copy, copyObj } from "./copy.js";
const mergeMapWith = (f, dest, ...xs) => {
const mergeMapWith = (f, dest, ...maps) => {
const res = copy(dest, Map);
for (let x of xs) {
for (let x of maps) {
if (x != null) {

@@ -14,5 +14,5 @@ for (let [k, v] of x) {

};
const mergeObjWith = (f, dest, ...xs) => meldObjWith(f, copyObj(dest), ...xs);
const meldObjWith = (f, dest, ...xs) => {
for (let x of xs) {
const mergeObjWith = (f, dest, ...objects) => meldObjWith(f, copyObj(dest), ...objects);
const meldObjWith = (f, dest, ...objects) => {
for (let x of objects) {
if (x != null) {

@@ -19,0 +19,0 @@ for (let k in x) {

@@ -7,5 +7,5 @@ import type { IObjectOf, Nullable } from "@thi.ng/api";

* @param dest - target map
* @param xs - input maps
* @param maps - input maps
*/
export declare const mergeMap: <K, V>(dest: Map<K, V>, ...xs: Nullable<Map<K, V>>[]) => Map<K, V>;
export declare const mergeMap: <K, V>(dest: Map<K, V>, ...maps: Nullable<Map<K, V>>[]) => Map<K, V>;
/**

@@ -16,5 +16,5 @@ * Merges all given objects in left-to-right order into `dest`.

* @param dest - target object
* @param xs - input objects
* @param objects - input objects
*/
export declare const mergeObj: <T>(dest: IObjectOf<T>, ...xs: Nullable<IObjectOf<T>>[]) => IObjectOf<T>;
export declare const mergeObj: <T>(dest: IObjectOf<T>, ...objects: Nullable<IObjectOf<T>>[]) => IObjectOf<T>;
//# sourceMappingURL=merge.d.ts.map

@@ -1,3 +0,3 @@

const mergeMap = (dest, ...xs) => {
for (let x of xs) {
const mergeMap = (dest, ...maps) => {
for (let x of maps) {
if (x != null) {

@@ -11,3 +11,3 @@ for (let pair of x) {

};
const mergeObj = (dest, ...xs) => Object.assign(dest, ...xs);
const mergeObj = (dest, ...objects) => Object.assign(dest, ...objects);
export {

@@ -14,0 +14,0 @@ mergeMap,

@@ -33,3 +33,3 @@ import type { Fn0, IObjectOf, Maybe, Nullable, Pair } from "@thi.ng/api";

add(key: K, val: V): void;
into(xs: Iterable<[K, V]>): void;
into(pairs: Iterable<[K, V]>): void;
delete(prefix: K, val?: V): boolean;

@@ -36,0 +36,0 @@ protected queueChildren(queue: [string, MultiTrie<any, any>][], prefix: string, sep?: string): void;

@@ -111,4 +111,4 @@ import { isArray } from "@thi.ng/checks/is-array";

}
into(xs) {
for (let [k, v] of xs) {
into(pairs) {
for (let [k, v] of pairs) {
this.add(k, v);

@@ -115,0 +115,0 @@ }

{
"name": "@thi.ng/associative",
"version": "6.3.60",
"version": "6.3.61",
"description": "Alternative Map and Set implementations with customizable equality semantics & supporting operations, plain object utilities",

@@ -13,3 +13,3 @@ "type": "module",

},
"homepage": "https://github.com/thi-ng/umbrella/tree/develop/packages/associative#readme",
"homepage": "https://thi.ng/associative",
"funding": [

@@ -40,19 +40,19 @@ {

"dependencies": {
"@thi.ng/api": "^8.11.2",
"@thi.ng/arrays": "^2.9.6",
"@thi.ng/binary": "^3.4.25",
"@thi.ng/checks": "^3.6.4",
"@thi.ng/compare": "^2.3.5",
"@thi.ng/dcons": "^3.2.113",
"@thi.ng/equiv": "^2.1.58",
"@thi.ng/errors": "^2.5.7",
"@thi.ng/random": "^3.8.0",
"@thi.ng/transducers": "^9.0.5",
"tslib": "^2.6.2"
"@thi.ng/api": "^8.11.3",
"@thi.ng/arrays": "^2.9.7",
"@thi.ng/binary": "^3.4.26",
"@thi.ng/checks": "^3.6.5",
"@thi.ng/compare": "^2.3.6",
"@thi.ng/dcons": "^3.2.114",
"@thi.ng/equiv": "^2.1.59",
"@thi.ng/errors": "^2.5.8",
"@thi.ng/random": "^3.8.1",
"@thi.ng/transducers": "^9.0.6",
"tslib": "^2.6.3"
},
"devDependencies": {
"@microsoft/api-extractor": "^7.43.2",
"esbuild": "^0.21.1",
"@microsoft/api-extractor": "^7.47.0",
"esbuild": "^0.21.5",
"typedoc": "^0.25.13",
"typescript": "^5.4.5"
"typescript": "^5.5.2"
},

@@ -202,3 +202,3 @@ "keywords": [

},
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
}

@@ -10,3 +10,3 @@ <!-- This file is generated - DO NOT EDIT! -->

> [!NOTE]
> This is one of 192 standalone projects, maintained as part
> This is one of 193 standalone projects, maintained as part
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo

@@ -207,3 +207,3 @@ > and anti-framework.

Package sizes (brotli'd, pre-treeshake): ESM: 6.97 KB
Package sizes (brotli'd, pre-treeshake): ESM: 6.98 KB

@@ -230,7 +230,8 @@ ## Dependencies

| Screenshot | Description | Live demo | Source |
|:--------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------|:---------------------------------------------------------|:--------------------------------------------------------------------------------------|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/commit-heatmap.png" width="240"/> | Heatmap visualization of this mono-repo's commits | | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/commit-heatmap) |
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rdom-key-sequences.jpg" width="240"/> | rstream & transducer-based FSM for converting key event sequences into high-level commands | [Demo](https://demo.thi.ng/umbrella/rdom-key-sequences/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-key-sequences) |
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/related-images.jpg" width="240"/> | Responsive image gallery with tag-based Jaccard similarity ranking | [Demo](https://demo.thi.ng/umbrella/related-images/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/related-images) |
| Screenshot | Description | Live demo | Source |
|:------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------|:-------------------------------------------------------------|:------------------------------------------------------------------------------------------|
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/commit-heatmap.png" width="240"/> | Heatmap visualization of this mono-repo's commits | | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/commit-heatmap) |
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/geom-webgl-attrib-pool.jpg" width="240"/> | Augmenting thi.ng/geom shapes for WebGL, using instancing & attribute buffers | [Demo](https://demo.thi.ng/umbrella/geom-webgl-attrib-pool/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/geom-webgl-attrib-pool) |
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/rdom-key-sequences.jpg" width="240"/> | rstream & transducer-based FSM for converting key event sequences into high-level commands | [Demo](https://demo.thi.ng/umbrella/rdom-key-sequences/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/rdom-key-sequences) |
| <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/related-images.jpg" width="240"/> | Responsive image gallery with tag-based Jaccard similarity ranking | [Demo](https://demo.thi.ng/umbrella/related-images/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/related-images) |

@@ -237,0 +238,0 @@ ## API

@@ -32,3 +32,3 @@ import type { Fn2, Nullable } from "@thi.ng/api";

*/
export declare const renameKeysObj: <T>(src: T, km: { [id in keyof T]?: PropertyKey | undefined; }, out?: any) => any;
export declare const renameKeysObj: <T>(src: T, km: { [id in keyof T]?: PropertyKey; }, out?: any) => any;
/**

@@ -35,0 +35,0 @@ * Similar to (combination of) {@link renameKeysObj} and

@@ -17,3 +17,3 @@ var __defProp = Object.defineProperty;

const __private = /* @__PURE__ */ new WeakMap();
const fail = () => illegalArgs(`dense & sparse arrays must be of same size`);
const __fail = () => illegalArgs(`dense & sparse arrays must be of same size`);
let ASparseSet = class extends Set {

@@ -132,3 +132,3 @@ constructor(dense, sparse) {

constructor(n, sparse) {
isNumber(n) ? super(new Uint8Array(n), new Uint8Array(n)) : n.length === sparse.length ? super(n, sparse) : fail();
isNumber(n) ? super(new Uint8Array(n), new Uint8Array(n)) : n.length === sparse.length ? super(n, sparse) : __fail();
}

@@ -150,3 +150,3 @@ get [Symbol.species]() {

constructor(n, sparse) {
isNumber(n) ? super(new Uint16Array(n), new Uint16Array(n)) : n.length === sparse.length ? super(n, sparse) : fail();
isNumber(n) ? super(new Uint16Array(n), new Uint16Array(n)) : n.length === sparse.length ? super(n, sparse) : __fail();
}

@@ -168,3 +168,3 @@ get [Symbol.species]() {

constructor(n, sparse) {
isNumber(n) ? super(new Uint32Array(n), new Uint32Array(n)) : n.length === sparse.length ? super(n, sparse) : fail();
isNumber(n) ? super(new Uint32Array(n), new Uint32Array(n)) : n.length === sparse.length ? super(n, sparse) : __fail();
}

@@ -171,0 +171,0 @@ get [Symbol.species]() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc