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

@thi.ng/paths

Package Overview
Dependencies
Maintainers
0
Versions
200
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@thi.ng/paths - npm Package Compare versions

Comparing version 5.1.81 to 5.1.82

9

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

@@ -12,2 +12,9 @@

### [5.1.82](https://github.com/thi-ng/umbrella/tree/@thi.ng/paths@5.1.82) (2024-06-21)
#### ♻️ Refactoring
- rename various rest args to be more semantically meaningful ([8088a56](https://github.com/thi-ng/umbrella/commit/8088a56))
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
### [5.1.79](https://github.com/thi-ng/umbrella/tree/@thi.ng/paths@5.1.79) (2024-04-20)

@@ -14,0 +21,0 @@

16

delete-in.d.ts

@@ -7,7 +7,9 @@ import type { Keys, Keys1, Keys2, Keys3, Keys4, Keys5, Keys6, Keys7, Path, Without, Without2, Without3, Without4, Without5, Without6, Without7, Without8 } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/delete-in-unsafe.ts
* import { deleteInUnsafe } from "@thi.ng/paths";
*
* // unchecked
* deleteInUnsafe({ a: { b: { c: 23 } } }, "a.b.c");
* console.log(
* deleteInUnsafe({ a: { b: { c: 23 } } }, "a.b.c")
* );
* // { a: { b: { } } }

@@ -32,10 +34,14 @@ * ```

* @example
* ```ts
* ```ts tangle:../export/delete-in.ts
* import { deleteIn } from "@thi.ng/paths";
*
* // type checked
* deleteIn({ a: { b: { c: 23 } } }, ["a","b","c"]);
* console.log(
* deleteIn({ a: { b: { c: 23 } } }, ["a","b","c"])
* );
*
* // error (invalid path)
* deleteIn({ a: { b: { c: 23 } } }, ["a","b","d"]);
* console.log(
* deleteIn({ a: { b: { c: 23 } } }, ["a","b","d"])
* );
* ```

@@ -42,0 +48,0 @@ *

@@ -11,6 +11,8 @@ import type { DeepPath, Maybe, OptPathVal, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8 } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/get-in-unsafe.ts
* import { getInUnsafe } from "@thi.ng/paths";
*
* getInUnsafe({ a: { b: { c: 23 } } }, "a.b.c");
* console.log(
* getInUnsafe({ a: { b: { c: 23 } } }, "a.b.c")
* );
* // 23

@@ -31,7 +33,9 @@ * ```

* @example
* ```ts
* ```ts tangle:../export/get-in.ts
* import { getIn } from "@thi.ng/paths";
*
* // type checked path and inferred return type
* getIn({ a: { b: { c: 23 } } }, ["a","b","c"]);
* console.log(
* getIn({ a: { b: { c: 23 } } }, ["a","b","c"])
* );
* // 23

@@ -38,0 +42,0 @@ * ```

@@ -12,3 +12,3 @@ import type { DeepPath, Fn, Maybe, OptPathVal, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8 } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/def-getter-unsafe.ts
* import { defGetterUnsafe } from "@thi.ng/paths";

@@ -18,5 +18,7 @@ *

*
* g({ a: { b: { c: 23} } }) // 23
* g({ x: 23 }) // undefined
* g() // undefined
* console.log(g({ a: { b: { c: 23} } }));
* // 23
*
* console.log(g({ x: 23 }));
* // undefined
* ```

@@ -47,3 +49,3 @@ *

* @example
* ```ts
* ```ts tangle:../export/def-getter.ts
* import { defGetter } from "@thi.ng/paths";

@@ -56,10 +58,15 @@ *

* // fully type checked getter
* g = defGetter<Foo, "a", "b", "c">(["a","b","c"]);
* const g = defGetter<Foo, "a", "b", "c">(["a","b","c"]);
*
* // error (wrong `d` key)
* g = defGetter<Foo, "a", "b", "d">(["a","b","d"]);
* // g = defGetter<Foo, "a", "b", "d">(["a","b","d"]);
*
* g({ a: { b: { c: 23} } }); // 23
* g({ x: 23 }); // error
* g(); // error
* console.log(g({ a: { b: { c: 23} } }));
* // 23
*
* // error
* console.log(g({ x: 23 }));
*
* // error
* console.log(g());
* ```

@@ -66,0 +73,0 @@ *

@@ -15,6 +15,6 @@ import type { Path } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/mut-in-many-unsafe.ts
* import { mutInManyUnsafe } from "@thi.ng/paths";
*
* mutInManyUnsafe(
* const res = mutInManyUnsafe(
* { a: { b: 1 }, x: { y: { z: 2 } } },

@@ -25,3 +25,5 @@ * // pair #1

* "x.y.z", 20
* )
* );
*
* console.log(res);
* // { a: { b: 10 }, x: { y: { z: 20 } } }

@@ -37,3 +39,3 @@ * ```

export declare function mutInManyUnsafe<T>(state: T, p1: Path, v1: any, p2: Path, v2: any, p3: Path, v3: any, p4: Path, v4: any): T;
export declare function mutInManyUnsafe<T>(state: T, p1: Path, v1: any, p2: Path, v2: any, p3: Path, v3: any, p4: Path, v4: any, ...xs: any[]): T;
export declare function mutInManyUnsafe<T>(state: T, p1: Path, v1: any, p2: Path, v2: any, p3: Path, v3: any, p4: Path, v4: any, ...pairs: any[]): T;
//# sourceMappingURL=mut-in-many.d.ts.map

@@ -12,10 +12,14 @@ import type { DeepPath, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, PathVal } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/mut-in-unsafe.ts
* import { mutInUnsafe } from "@thi.ng/paths";
*
* mutInUnsafe({ a: { b: [10, 20] } }, "a.b.1", 23);
* console.log(
* mutInUnsafe({ a: { b: [10, 20] } }, "a.b.1", 23)
* );
* // { a: { b: [ 10, 23 ] } }
*
* // fails (see `defMutator()` docs)
* mutInUnsafe({}, "a.b.c", 23);
* console.log(
* mutInUnsafe({}, "a.b.c", 23)
* );
* // undefined

@@ -39,6 +43,8 @@ * ```

* @example
* ```ts
* import { muIn } from "@thi.ng/paths";
* ```ts tangle:../export/mut-in.ts
* import { mutIn } from "@thi.ng/paths";
*
* mutIn({ a: { b: [10, 20] } }, ["a", "b", 1], 23)
* console.log(
* mutIn({ a: { b: [10, 20] } }, ["a", "b", 1], 23)
* );
* // { a: { b: [ 10, 23 ] } }

@@ -45,0 +51,0 @@ * ```

{
"name": "@thi.ng/paths",
"version": "5.1.81",
"version": "5.1.82",
"description": "Immutable, optimized and optionally typed path-based object property / array accessors with structural sharing",

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

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

@@ -40,11 +40,11 @@ {

"dependencies": {
"@thi.ng/api": "^8.11.2",
"@thi.ng/checks": "^3.6.4",
"@thi.ng/errors": "^2.5.7"
"@thi.ng/api": "^8.11.3",
"@thi.ng/checks": "^3.6.5",
"@thi.ng/errors": "^2.5.8"
},
"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"
},

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

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

@@ -12,12 +12,12 @@ import type { NumOrString, Path } from "@thi.ng/api";

*
* ```ts
* ```ts tangle:../export/to-path.ts
* import { toPath } from "@thi.ng/paths";
*
* toPath("a.b.c");
* console.log(toPath("a.b.c"));
* // ["a", "b", "c"]
*
* toPath(0)
* console.log(toPath(0));
* // [0]
*
* toPath(["a", "b", "c"])
* console.log(toPath(["a", "b", "c"]));
* // ["a", "b", "c"]

@@ -24,0 +24,0 @@ * ```

@@ -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

@@ -13,0 +13,0 @@ > and anti-framework.

@@ -16,6 +16,6 @@ import type { Path } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/set-in-many-unsafe.ts
* import { setInManyUnsafe } from "@thi.ng/paths";
*
* setInManyUnsafe(
* const res = setInManyUnsafe(
* {},

@@ -27,2 +27,4 @@ * // pair #1

* );
*
* console.log(res);
* // { a: { b: 10 }, x: { y: { z: 20 } } }

@@ -38,3 +40,3 @@ * ```

export declare function setInManyUnsafe<T>(state: T, p1: Path, v1: any, p2: Path, v2: any, p3: Path, v3: any, p4: Path, v4: any): T;
export declare function setInManyUnsafe<T>(state: T, p1: Path, v1: any, p2: Path, v2: any, p3: Path, v3: any, p4: Path, v4: any, ...xs: any[]): T;
export declare function setInManyUnsafe<T>(state: T, p1: Path, v1: any, p2: Path, v2: any, p3: Path, v3: any, p4: Path, v4: any, ...pairs: any[]): T;
//# sourceMappingURL=set-in-many.d.ts.map

@@ -10,6 +10,8 @@ import type { DeepPath, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, PathVal } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/set-in-unsafe.ts
* import { setInUnsafe } from "@thi.ng/paths";
*
* setInUnsafe({}, "a.b.c", 23);
* console.log(
* setInUnsafe({}, "a.b.c", 23)
* );
* // { a: { b: { c: 23} } }

@@ -30,11 +32,15 @@ * ```

* @example
* ```ts
* ```ts tangle:../export/set-in.ts
* import { setIn } from "@thi.ng/paths";
*
* // type checked path & value
* setIn({ a: { b: { c: 23 } } }, ["a", "b", "c"], 24);
* console.log(
* setIn({ a: { b: { c: 23 } } }, ["a", "b", "c"], 24)
* );
* // { a: { b: { c: 24 } } }
*
* // error (wrong value type)
* setIn({ a: { b: { c: 23 } } }, ["a", "b", "c"], "24");
* console.log(
* setIn({ a: { b: { c: 23 } } }, ["a", "b", "c"], "24")
* );
* ```

@@ -41,0 +47,0 @@ *

@@ -31,16 +31,22 @@ import type { DeepPath, Fn2, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, PathVal } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/def-setter-unsafe.ts
* import { defSetterUnsafe } from "@thi.ng/paths";
*
* s = defSetterUnsafe("a.b.c");
* const s = defSetterUnsafe("a.b.c");
* // or
* s = defSetterUnsafe(["a", "b", "c"]);
* // const s = defSetterUnsafe(["a", "b", "c"]);
*
* s({ a: { b: { c: 23} } }, 24)
* console.log(
* s({ a: { b: { c: 23} } }, 24)
* );
* // { a: { b: { c: 24} } }
*
* s({ x: 23 }, 24)
* console.log(
* s({ x: 23 }, 24)
* );
* // { x: 23, a: { b: { c: 24 } } }
*
* s(null, 24)
* console.log(
* s(null, 24)
* );
* // { a: { b: { c: 24 } } }

@@ -50,13 +56,15 @@ * ```

* @example
* ```ts
* ```ts tangle:../export/def-setter-unsafe-2.ts
* import { defSetterUnsafe } from "@thi.ng/paths";
*
* s = defSetterUnsafe("a.b.c");
* const s = defSetterUnsafe("a.b.c");
*
* a = { x: { y: { z: 1 } } };
* b = s(a, 2);
* const a = { x: { y: { z: 1 } } };
* const b = s(a, 2);
*
* console.log(b);
* // { x: { y: { z: 1 } }, a: { b: { c: 2 } } }
*
* a.x === b.x // true
* a.x.y === b.x.y // true
* console.log(a.x === b.x); // true
* console.log(a.x.y === b.x.y); // true
* ```

@@ -77,3 +85,3 @@ *

* @example
* ```ts
* ```ts tangle:../export/def-setter.ts
* import { defSetter } from "@thi.ng/paths";

@@ -90,3 +98,3 @@ *

* @example
* ```ts
* ```ts tangle:../export/def-setter-2.ts
* import { defSetter } from "@thi.ng/paths";

@@ -93,0 +101,0 @@ *

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

for (let i = ks.length; i-- > 0; ) {
f = compS(ks[i], f);
f = __compSetter(ks[i], f);
}

@@ -50,3 +50,3 @@ return f;

const copy = (x) => isArray(x) || isTypedArray(x) ? x.slice() : { ...x };
const compS = (k, f) => (s, v) => {
const __compSetter = (k, f) => (s, v) => {
s = copy(s);

@@ -53,0 +53,0 @@ s[k] = f ? f(s[k], v) : v;

import type { DeepPath, OptPathVal, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, PathVal } from "@thi.ng/api";
import type { UpdateFn } from "./api.js";
/**
* Similar to {@link setInUnsafe}, but applies given function to current
* path value (incl. any additional/optional arguments passed to
* `updateIn`) and uses result as new value. Does not modify original
* state.
* Similar to {@link setInUnsafe}, but applies given function to current path
* value (incl. any additional/optional arguments passed to `updateIn`) and uses
* result as new value. Does **not** modify original state.
*
* @remarks
* Unchecked version of {@link updateIn}. The type parameter `T` can be
* used to indicate the type of the nested value to be updated (default:
* `any`).
* Unchecked version of {@link updateIn}. The type parameter `T` can be used to
* indicate the type of the nested value to be updated (default: `any`).
*
* @example
* ```ts
* import { updateInUnsafe } from "@thi.ng/paths";
* ```ts tangle:../export/update-in-unsafe.ts
* import { updateIn, updateInUnsafe } from "@thi.ng/paths";
*
* add = (x: number, y: number) => x + y;
* updateInUnsafe({ a: { b: { c: 23 } } }, "a.b.c", add, 10);
* const add = (x: number, y: number) => x + y;
*
* console.log(
* updateInUnsafe({ a: { b: { c: 23 } } }, "a.b.c", add, 10)
* );
* // { a: { b: { c: 33 } } }
*
* // type checked
* updateIn({ a: { b: { c: 23 } } }, ["a","b","c"], add, 10);
* console.log(
* updateIn({ a: { b: { c: 23 } } }, ["a", "b", "c"], add, 10)
* );
* // { a: { b: { c: 33 } } }
*
* // type error (value at "a.b" is not a number)
* updateIn({ a: { b: { c: 23 } } }, ["a","b"], add, 10);
* // updateIn({ a: { b: { c: 23 } } }, ["a", "b"], add, 10)
* ```

@@ -29,0 +32,0 @@ *

@@ -17,3 +17,3 @@ import type { DeepPath, FnO, OptPathVal, Path, Path0, Path1, Path2, Path3, Path4, Path5, Path6, Path7, Path8, PathVal } from "@thi.ng/api";

* @example
* ```ts
* ```ts tangle:../export/def-update-unsafe.ts
* import { defUpdaterUnsafe } from "@thi.ng/paths";

@@ -23,5 +23,7 @@ *

* // or
* const incB = defUpdaterUnsafe(["a", "b"], (x, n) => x + n);
* // const incB = defUpdaterUnsafe(["a", "b"], (x, n) => x + n);
*
* incB({ a: { b: 10 } }, 13);
* console.log(
* incB({ a: { b: 10 } }, 13)
* );
* // { a: { b: 23 } }

@@ -28,0 +30,0 @@ * ```

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