@synnaxlabs/x 0.45.0 → 0.45.1

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.
Files changed (62) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/dist/deep.cjs +1 -1
  3. package/dist/deep.js +211 -99
  4. package/dist/external-CtHGFcox.cjs +1 -0
  5. package/dist/{external-BM_NS5yM.js → external-tyaEMW4S.js} +1 -1
  6. package/dist/get-CXkBfLu1.js +82 -0
  7. package/dist/get-OP63N4c3.cjs +1 -0
  8. package/dist/index.cjs +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/src/deep/copy.spec.d.ts +2 -0
  11. package/dist/src/deep/copy.spec.d.ts.map +1 -0
  12. package/dist/src/deep/external.d.ts +3 -1
  13. package/dist/src/deep/external.d.ts.map +1 -1
  14. package/dist/src/deep/get.bench.d.ts +2 -0
  15. package/dist/src/deep/get.bench.d.ts.map +1 -0
  16. package/dist/src/deep/get.d.ts +16 -0
  17. package/dist/src/deep/get.d.ts.map +1 -0
  18. package/dist/src/deep/get.spec.d.ts +2 -0
  19. package/dist/src/deep/get.spec.d.ts.map +1 -0
  20. package/dist/src/deep/partial.spec.d.ts +2 -0
  21. package/dist/src/deep/partial.spec.d.ts.map +1 -0
  22. package/dist/src/deep/path.d.ts +4 -92
  23. package/dist/src/deep/path.d.ts.map +1 -1
  24. package/dist/src/deep/remove.bench.d.ts +2 -0
  25. package/dist/src/deep/remove.bench.d.ts.map +1 -0
  26. package/dist/src/deep/remove.d.ts +2 -0
  27. package/dist/src/deep/remove.d.ts.map +1 -0
  28. package/dist/src/deep/remove.spec.d.ts +2 -0
  29. package/dist/src/deep/remove.spec.d.ts.map +1 -0
  30. package/dist/src/deep/set.bench.d.ts +2 -0
  31. package/dist/src/deep/set.bench.d.ts.map +1 -0
  32. package/dist/src/deep/set.d.ts +2 -0
  33. package/dist/src/deep/set.d.ts.map +1 -0
  34. package/dist/src/deep/set.spec.d.ts +2 -0
  35. package/dist/src/deep/set.spec.d.ts.map +1 -0
  36. package/dist/zod.cjs +1 -1
  37. package/dist/zod.js +1 -1
  38. package/package.json +2 -2
  39. package/src/deep/copy.spec.ts +148 -0
  40. package/src/deep/external.ts +3 -1
  41. package/src/deep/get.bench.ts +170 -0
  42. package/src/deep/get.spec.ts +196 -0
  43. package/src/deep/get.ts +79 -0
  44. package/src/deep/partial.spec.ts +194 -0
  45. package/src/deep/path.spec.ts +92 -183
  46. package/src/deep/path.ts +27 -198
  47. package/src/deep/remove.bench.ts +238 -0
  48. package/src/deep/remove.spec.ts +219 -0
  49. package/src/deep/remove.ts +102 -0
  50. package/src/deep/set.bench.ts +208 -0
  51. package/src/deep/set.spec.ts +369 -0
  52. package/src/deep/set.ts +91 -0
  53. package/tsconfig.tsbuildinfo +1 -1
  54. package/dist/external-E3ErJeeM.cjs +0 -1
  55. package/dist/path-Blh4wJuA.js +0 -110
  56. package/dist/path-CPSfCjde.cjs +0 -1
  57. package/dist/src/deep/delete.d.ts +0 -3
  58. package/dist/src/deep/delete.d.ts.map +0 -1
  59. package/dist/src/deep/delete.spec.d.ts +0 -2
  60. package/dist/src/deep/delete.spec.d.ts.map +0 -1
  61. package/src/deep/delete.spec.ts +0 -73
  62. package/src/deep/delete.ts +0 -27
@@ -1,8 +1,10 @@
1
1
  export * from './copy';
2
- export * from './delete';
3
2
  export * from './difference';
4
3
  export * from './equal';
4
+ export * from './get';
5
5
  export * from './merge';
6
6
  export * from './partial';
7
7
  export * from './path';
8
+ export * from './remove';
9
+ export * from './set';
8
10
  //# sourceMappingURL=external.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/deep/external.ts"],"names":[],"mappings":"AASA,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../../../src/deep/external.ts"],"names":[],"mappings":"AASA,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=get.bench.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.bench.d.ts","sourceRoot":"","sources":["../../../src/deep/get.bench.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { record } from '../record';
2
+ export interface GetOptions<O extends boolean | undefined = boolean | undefined> {
3
+ optional: O;
4
+ getter?: (obj: record.Unknown, key: string) => unknown;
5
+ }
6
+ export interface Get {
7
+ <V = record.Unknown, T = record.Unknown>(obj: T, path: string, options?: GetOptions<false>): V;
8
+ <V = record.Unknown, T = record.Unknown>(obj: T, path: string, options?: GetOptions<boolean | undefined>): V | null;
9
+ }
10
+ export interface TypedGet<V = record.Unknown, T = record.Unknown> {
11
+ (obj: T, path: string, options?: GetOptions<false>): V;
12
+ (obj: T, path: string, options?: GetOptions<boolean | undefined>): V | null;
13
+ }
14
+ export declare const get: Get;
15
+ export declare const has: <V = record.Unknown, T = record.Unknown>(obj: T, path: string) => boolean;
16
+ //# sourceMappingURL=get.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/deep/get.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,WAAW,UAAU,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS;IAC7E,QAAQ,E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ceRoot":"","sources":["../../../src/deep/get.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=partial.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"partial.spec.d.ts","sourceRoot":"","sources":["../../../src/deep/partial.spec.ts"],"names":[],"mappings":""}
@@ -1,5 +1,6 @@
1
1
  import { Join } from '../join';
2
2
  import { record } from '../record';
3
+ export declare const SEPARATOR = ".";
3
4
  type Prev = [
4
5
  never,
5
6
  0,
@@ -25,104 +26,15 @@ type Prev = [
25
26
  20,
26
27
  ...0[]
27
28
  ];
28
- /**
29
- * A type that represents a deep key in an object.
30
- * @example type Key<T, 3> = "a" | "a.b" | "a.b.c"
31
- */
32
29
  export type Key<T, D extends number = 5> = [D] extends [never] ? never : T extends object ? {
33
30
  [K in keyof T]-?: K extends string | number ? `${K}` | Join<K, Key<T[K], Prev[D]>> : never;
34
31
  }[keyof T] : "";
35
- /** Options for the get function. */
36
- export interface GetOptions<O extends boolean | undefined = boolean | undefined> {
37
- optional: O;
38
- getter?: (obj: record.Unknown, key: string) => unknown;
39
- separator?: string;
40
- }
41
- /**
42
- * A function that gets the value at the given path on the object. If the path does not exist
43
- * and the optional flag is set to true, null will be returned. If the path does not exist and
44
- * the optional flag is set to false, an error will be thrown.
45
- * @param obj the object to get the value from.
46
- * @param path the path to get the value at.
47
- * @param options the options for getting the value.
48
- * @param options.optional whether the path is optional.
49
- * @param options.getter a custom getter function to use on each part of the path.
50
- * @returns the value at the given path on the object.
51
- */
52
- export interface Get {
53
- <V = record.Unknown, T = record.Unknown>(obj: T, path: string, options?: GetOptions<false>): V;
54
- <V = record.Unknown, T = record.Unknown>(obj: T, path: string, options?: GetOptions<boolean | undefined>): V | null;
55
- }
56
- /** A strongly typed version of the @link Get function. */
57
- export interface TypedGet<V = record.Unknown, T = record.Unknown> {
58
- (obj: T, path: string, options?: GetOptions<false>): V;
59
- (obj: T, path: string, options?: GetOptions<boolean | undefined>): V | null;
60
- }
61
- /**
62
- * Executes the given replacer function on each part of the path.
63
- * @param path the path to transform
64
- * @param replacer the function to execute on each part of the path. If multiple
65
- * parts are returned, they will be joined with a period. If null/undefined is returned,
66
- * the part will be removed from the path.
67
- * @returns the transformed path.
68
- */
69
32
  export declare const transformPath: (path: string, replacer: (part: string, index: number, parts: string[]) => string | string[] | undefined, separator?: string) => string;
33
+ export declare const defaultGetter: (obj: record.Unknown, key: string) => unknown;
70
34
  export declare const resolvePath: <T = record.Unknown>(path: string, obj: T) => string;
71
- /**
72
- * Gets the value at the given path on the object. If the path does not exist
73
- * and the optional flag is set to true, null will be returned. If the path does
74
- * not exist and the optional flag is set to false, an error will be thrown.
75
- * @param obj the object to get the value from.
76
- * @param path the path to get the value at.
77
- * @param opts the options for getting the value.
78
- * @param opts.optional whether the path is optional.
79
- * @param opts.getter a custom getter function to use on each part of the path.
80
- * @returns the value at the given path on the object.
81
- */
82
- export declare const get: Get;
83
- /**
84
- * Sets the value at the given path on the object. If the parents of the deep path
85
- * do not exist, new objects will be created.
86
- * @param obj the object to set the value on.
87
- * @param path the path to set the value at.
88
- * @param value the value to set.
89
- */
90
- export declare const set: <V>(obj: V, path: string, value: unknown) => void;
91
- /**
92
- * Removes the value at the given path, modifying the object in place.
93
- * @param obj the object to remove the value from.
94
- * @param path the path to remove the value from.
95
- * @returns the object with the value removed.
96
- */
97
- export declare const remove: <V>(obj: V, path: string) => void;
98
- /**
99
- * Returns the element at the given index in the path.
100
- * @param path the path to get the element from
101
- * @param index the index of the element to get
102
- * @returns the element at the given index in the path
103
- */
104
35
  export declare const element: (path: string, index: number) => string;
105
- /**
106
- * Checks if the path exists in the object.
107
- * @param obj the object to check
108
- * @param path the path to check
109
- * @returns whether the path exists in the object
110
- */
111
- export declare const has: <V = record.Unknown, T = record.Unknown>(obj: T, path: string) => boolean;
112
- /**
113
- * Checks if the path matches the given pattern.
114
- *
115
- * @param path The path to check.
116
- * @param pattern The pattern to match against. Only "*" is supported as a wildcard.
117
- * @returns Whether the path matches the pattern.
118
- *
119
- * * @example
120
- * pathsMatch("a.b.c", "a.b.c") // true
121
- * pathsMatch("a.b.c", "a.b") // true
122
- * pathsMatch("a.b", "a.b.c") // false
123
- * pathsMatch("a.b.c", "a.*") // true
124
- * pathsMatch("a.b.c", "a.*.c") // true
125
- */
126
36
  export declare const pathsMatch: (path: string, pattern: string) => boolean;
37
+ export declare const getIndex: (part: string) => number | null;
38
+ export declare const findBestKey: (obj: record.Unknown, remainingParts: string[]) => [string, number] | null;
127
39
  export {};
128
40
  //# sourceMappingURL=path.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/deep/path.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,KAAK,IAAI,GAAG;IACV,KAAK;IACL,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,CAAC;IACD,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,EAAE;IACF,GAAG,CAAC,EAAE;CACP,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GAC1D,KAAK,GACL,CAAC,SAAS,MAAM,GACd;KACG,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,SAAS,MAAM,GAAG,MAAM,GACvC,GAAG,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC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D,CAAC;AAEF,eAAO,MAAM,QAAQ,GAAI,MAAM,MAAM,KAAG,MAAM,GAAG,IAIhD,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,KAAK,MAAM,CAAC,OAAO,EACnB,gBAAgB,MAAM,EAAE,KACvB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAOrB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remove.bench.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.bench.d.ts","sourceRoot":"","sources":["../../../src/deep/remove.bench.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const remove: <V>(obj: V, path: string) => void;
2
+ //# sourceMappingURL=remove.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.d.ts","sourceRoot":"","sources":["../../../src/deep/remove.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,MAAM,GAAI,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,MAAM,KAAG,IAyFhD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remove.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove.spec.d.ts","sourceRoot":"","sources":["../../../src/deep/remove.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=set.bench.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.bench.d.ts","sourceRoot":"","sources":["../../../src/deep/set.bench.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const set: <V>(obj: V, path: string, value: unknown) => void;
2
+ //# sourceMappingURL=set.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../../src/deep/set.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,GAAG,GAAI,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,MAAM,EAAE,OAAO,OAAO,KAAG,IA8E7D,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=set.spec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set.spec.d.ts","sourceRoot":"","sources":["../../../src/deep/set.spec.ts"],"names":[],"mappings":""}
package/dist/zod.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-E3ErJeeM.cjs");exports.zod=e.external;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./external-CtHGFcox.cjs");exports.zod=e.external;
package/dist/zod.js CHANGED
@@ -1,4 +1,4 @@
1
- import { e as r } from "./external-BM_NS5yM.js";
1
+ import { e as r } from "./external-tyaEMW4S.js";
2
2
  export {
3
3
  r as zod
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synnaxlabs/x",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "type": "module",
5
5
  "description": "Common Utilities for Synnax Labs",
6
6
  "repository": "https://github.com/synnaxlabs/synnax/tree/main/x/ts",
@@ -27,8 +27,8 @@
27
27
  "typescript": "^5.8.3",
28
28
  "vite": "^7.0.4",
29
29
  "vitest": "^3.2.4",
30
- "@synnaxlabs/tsconfig": "^0.43.0",
31
30
  "@synnaxlabs/vite-plugin": "^0.43.0",
31
+ "@synnaxlabs/tsconfig": "^0.43.0",
32
32
  "eslint-config-synnaxlabs": "^0.43.0"
33
33
  },
34
34
  "main": "./dist/index.cjs",
@@ -0,0 +1,148 @@
1
+ // Copyright 2025 Synnax Labs, Inc.
2
+ //
3
+ // Use of this software is governed by the Business Source License included in the file
4
+ // licenses/BSL.txt.
5
+ //
6
+ // As of the Change Date specified in that file, in accordance with the Business Source
7
+ // License, use of this software will be governed by the Apache License, Version 2.0,
8
+ // included in the file licenses/APL.txt.
9
+
10
+ import { describe, expect, it } from "vitest";
11
+
12
+ import { deep } from "@/deep";
13
+
14
+ describe("copy", () => {
15
+ it("should deep copy a simple object", () => {
16
+ const obj = { a: 1, b: 2 };
17
+ const copied = deep.copy(obj);
18
+ expect(copied).toEqual(obj);
19
+ expect(copied).not.toBe(obj);
20
+ });
21
+
22
+ it("should deep copy nested objects", () => {
23
+ const obj = { a: 1, b: { c: 2, d: { e: 3 } } };
24
+ const copied = deep.copy(obj);
25
+ expect(copied).toEqual(obj);
26
+ expect(copied).not.toBe(obj);
27
+ expect(copied.b).not.toBe(obj.b);
28
+ expect(copied.b.d).not.toBe(obj.b.d);
29
+ });
30
+
31
+ it("should deep copy arrays", () => {
32
+ const obj = { a: [1, 2, 3], b: [{ c: 4 }, { d: 5 }] };
33
+ const copied = deep.copy(obj);
34
+ expect(copied).toEqual(obj);
35
+ expect(copied.a).not.toBe(obj.a);
36
+ expect(copied.b).not.toBe(obj.b);
37
+ expect(copied.b[0]).not.toBe(obj.b[0]);
38
+ });
39
+
40
+ it("should handle null values", () => {
41
+ const obj = { a: null, b: { c: null } };
42
+ const copied = deep.copy(obj);
43
+ expect(copied).toEqual(obj);
44
+ expect(copied).not.toBe(obj);
45
+ });
46
+
47
+ it("should handle undefined values", () => {
48
+ const obj = { a: undefined, b: { c: undefined } };
49
+ const copied = deep.copy(obj);
50
+ expect(copied).toEqual(obj);
51
+ expect(copied).not.toBe(obj);
52
+ });
53
+
54
+ it("should handle Date objects", () => {
55
+ const date = new Date("2025-01-01");
56
+ const obj = { a: date, b: { c: date } };
57
+ const copied = deep.copy(obj);
58
+ expect(copied.a).toEqual(date);
59
+ expect(copied.a).not.toBe(date);
60
+ expect(copied.b.c).toEqual(date);
61
+ expect(copied.b.c).not.toBe(date);
62
+ });
63
+
64
+ it("should handle circular references with structuredClone", () => {
65
+ const obj: any = { a: 1 };
66
+ obj.circular = obj;
67
+
68
+ const copied = deep.copy(obj);
69
+
70
+ expect(copied.a).toBe(1);
71
+ expect(copied.circular).toBe(copied);
72
+ expect(copied).not.toBe(obj);
73
+ });
74
+
75
+ it("should handle Map objects", () => {
76
+ const map = new Map([
77
+ ["a", 1],
78
+ ["b", 2],
79
+ ]);
80
+ const obj = { map };
81
+ const copied = deep.copy(obj);
82
+ expect(copied.map).toEqual(map);
83
+ expect(copied.map).not.toBe(map);
84
+ });
85
+
86
+ it("should handle Set objects", () => {
87
+ const set = new Set([1, 2, 3]);
88
+ const obj = { set };
89
+ const copied = deep.copy(obj);
90
+ expect(copied.set).toEqual(set);
91
+ expect(copied.set).not.toBe(set);
92
+ });
93
+
94
+ it("should handle RegExp objects", () => {
95
+ const regex = /test/gi;
96
+ const obj = { regex };
97
+ const copied = deep.copy(obj);
98
+ expect(copied.regex).toEqual(regex);
99
+ expect(copied.regex).not.toBe(regex);
100
+ });
101
+
102
+ it("should handle mixed types", () => {
103
+ const obj = {
104
+ num: 42,
105
+ str: "test",
106
+ bool: true,
107
+ arr: [1, 2, { nested: "value" }],
108
+ obj: { a: 1, b: { c: 2 } },
109
+ date: new Date("2025-01-01"),
110
+ nil: null,
111
+ undef: undefined,
112
+ };
113
+ const copied = deep.copy(obj);
114
+ expect(copied).toEqual(obj);
115
+ expect(copied).not.toBe(obj);
116
+ expect(copied.arr).not.toBe(obj.arr);
117
+ expect(copied.obj).not.toBe(obj.obj);
118
+ expect(copied.date).not.toBe(obj.date);
119
+ });
120
+
121
+ it("should handle empty objects and arrays", () => {
122
+ const obj = { empty: {}, arr: [] };
123
+ const copied = deep.copy(obj);
124
+ expect(copied).toEqual(obj);
125
+ expect(copied.empty).not.toBe(obj.empty);
126
+ expect(copied.arr).not.toBe(obj.arr);
127
+ });
128
+
129
+ it("should preserve array length with sparse arrays", () => {
130
+ // eslint-disable-next-line no-sparse-arrays
131
+ const arr = [1, , , 4];
132
+ const copied = deep.copy(arr);
133
+ expect(copied).toEqual(arr);
134
+ expect(copied.length).toBe(4);
135
+ expect(copied[1]).toBeUndefined();
136
+ });
137
+
138
+ it("should handle Uint8Array and other typed arrays", () => {
139
+ const uint8 = new Uint8Array([1, 2, 3]);
140
+ const obj = { uint8 };
141
+ const copied = deep.copy(obj);
142
+ expect(copied.uint8).toBeDefined();
143
+ if (copied.uint8 instanceof Uint8Array) {
144
+ expect(Array.from(copied.uint8)).toEqual([1, 2, 3]);
145
+ expect(copied.uint8).not.toBe(uint8);
146
+ } else expect(Array.from(copied.uint8 as Uint8Array)).toEqual([1, 2, 3]);
147
+ });
148
+ });
@@ -8,9 +8,11 @@
8
8
  // included in the file licenses/APL.txt.
9
9
 
10
10
  export * from "@/deep/copy";
11
- export * from "@/deep/delete";
12
11
  export * from "@/deep/difference";
13
12
  export * from "@/deep/equal";
13
+ export * from "@/deep/get";
14
14
  export * from "@/deep/merge";
15
15
  export * from "@/deep/partial";
16
16
  export * from "@/deep/path";
17
+ export * from "@/deep/remove";
18
+ export * from "@/deep/set";
@@ -0,0 +1,170 @@
1
+ // Copyright 2025 Synnax Labs, Inc.
2
+ //
3
+ // Use of this software is governed by the Business Source License included in the file
4
+ // licenses/BSL.txt.
5
+ //
6
+ // As of the Change Date specified in that file, in accordance with the Business Source
7
+ // License, use of this software will be governed by the Apache License, Version 2.0,
8
+ // included in the file licenses/APL.txt.
9
+
10
+ import { bench, describe } from "vitest";
11
+
12
+ import { deep } from "@/deep";
13
+
14
+ describe("deep.get benchmarks", () => {
15
+ const shallowObject = {
16
+ a: 1,
17
+ b: 2,
18
+ c: 3,
19
+ d: 4,
20
+ e: 5,
21
+ };
22
+
23
+ const nestedObject = {
24
+ level1: {
25
+ level2: {
26
+ level3: {
27
+ level4: {
28
+ level5: {
29
+ value: 42,
30
+ },
31
+ },
32
+ },
33
+ },
34
+ },
35
+ };
36
+
37
+ const arrayObject = {
38
+ items: [
39
+ { key: "item1", value: 1 },
40
+ { key: "item2", value: 2 },
41
+ { key: "item3", value: 3 },
42
+ { key: "item4", value: 4 },
43
+ { key: "item5", value: 5 },
44
+ ],
45
+ };
46
+
47
+ const deeplyNestedArray = {
48
+ a: [
49
+ {
50
+ b: [
51
+ {
52
+ c: [{ value: 1 }, { value: 2 }, { value: 3 }],
53
+ },
54
+ ],
55
+ },
56
+ ],
57
+ };
58
+
59
+ const largeObject: any = {};
60
+ for (let i = 0; i < 1000; i++)
61
+ largeObject[`key${i}`] = {
62
+ nested: {
63
+ value: i,
64
+ data: {
65
+ id: i,
66
+ name: `name${i}`,
67
+ },
68
+ },
69
+ };
70
+
71
+ const veryDeepObject: any = {};
72
+ let current = veryDeepObject;
73
+ for (let i = 0; i < 100; i++) {
74
+ current.next = { level: i };
75
+ current = current.next;
76
+ }
77
+ current.value = "deep";
78
+
79
+ const keyedWithPeriods = {
80
+ channels: [
81
+ { key: "sensor.temperature.1", reading: 25.5 },
82
+ { key: "sensor.temperature.2", reading: 26.1 },
83
+ { key: "sensor.pressure.1", reading: 101.3 },
84
+ { key: "sensor.pressure.2", reading: 101.5 },
85
+ ],
86
+ };
87
+
88
+ bench("shallow property access", () => {
89
+ deep.get(shallowObject, "c");
90
+ });
91
+
92
+ bench("nested property access (5 levels)", () => {
93
+ deep.get(nestedObject, "level1.level2.level3.level4.level5.value");
94
+ });
95
+
96
+ bench("array index access", () => {
97
+ deep.get(arrayObject, "items.2");
98
+ });
99
+
100
+ bench("keyed array access", () => {
101
+ deep.get(arrayObject, "items.item3.value");
102
+ });
103
+
104
+ bench("mixed array and object access", () => {
105
+ deep.get(deeplyNestedArray, "a.0.b.0.c.1.value");
106
+ });
107
+
108
+ bench("large object property access", () => {
109
+ deep.get(largeObject, "key500.nested.data.name");
110
+ });
111
+
112
+ bench("very deep path (100 levels)", () => {
113
+ const path = `${new Array(99).fill("next").join(".")}.value`;
114
+ deep.get(veryDeepObject, path);
115
+ });
116
+
117
+ bench("optional path that doesn't exist", () => {
118
+ deep.get(nestedObject, "level1.nonexistent.path", { optional: true });
119
+ });
120
+
121
+ bench("keyed array with periods in keys", () => {
122
+ deep.get(keyedWithPeriods, "channels.sensor.temperature.1.reading");
123
+ });
124
+
125
+ bench("has() on existing path", () => {
126
+ deep.has(nestedObject, "level1.level2.level3");
127
+ });
128
+
129
+ bench("has() on non-existing path", () => {
130
+ deep.has(nestedObject, "level1.level2.nonexistent");
131
+ });
132
+
133
+ bench("has() on keyed array", () => {
134
+ deep.has(arrayObject, "items.item2");
135
+ });
136
+
137
+ const pathsWith100Keys: any = {};
138
+ let temp = pathsWith100Keys;
139
+ for (let i = 0; i < 100; i++) {
140
+ temp[`key_${i}`] = {};
141
+ temp = temp[`key_${i}`];
142
+ }
143
+ temp.final = "value";
144
+
145
+ bench("100 unique keys traversal", () => {
146
+ const path = Array.from({ length: 100 }, (_, i) => `key_${i}`).join(".");
147
+ deep.get(pathsWith100Keys, `${path}.final`);
148
+ });
149
+
150
+ bench("repeated get operations (cache test)", () => {
151
+ for (let i = 0; i < 10; i++)
152
+ deep.get(nestedObject, "level1.level2.level3.level4.level5.value");
153
+ });
154
+
155
+ bench("get with custom getter function", () => {
156
+ const obj = {
157
+ data: {
158
+ value: () => ({ result: 42 }),
159
+ },
160
+ };
161
+ deep.get(obj, "data.value().result", {
162
+ optional: false,
163
+ getter: (obj, key) => {
164
+ if (key === "value()")
165
+ return (obj as { value: () => { result: number } }).value();
166
+ return obj[key];
167
+ },
168
+ });
169
+ });
170
+ });