ts-data-forge 14.3.0 → 14.5.0

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 (59) hide show
  1. package/README.md +6 -0
  2. package/dist/array/impl/array-utils-search.d.mts.map +1 -1
  3. package/dist/array/impl/array-utils-search.mjs.map +1 -1
  4. package/dist/functional/optional/impl/index.d.mts +1 -0
  5. package/dist/functional/optional/impl/index.d.mts.map +1 -1
  6. package/dist/functional/optional/impl/index.mjs +1 -0
  7. package/dist/functional/optional/impl/index.mjs.map +1 -1
  8. package/dist/functional/optional/impl/optional-match.d.mts +48 -0
  9. package/dist/functional/optional/impl/optional-match.d.mts.map +1 -0
  10. package/dist/functional/optional/impl/optional-match.mjs +22 -0
  11. package/dist/functional/optional/impl/optional-match.mjs.map +1 -0
  12. package/dist/functional/result/impl/index.d.mts +4 -0
  13. package/dist/functional/result/impl/index.d.mts.map +1 -1
  14. package/dist/functional/result/impl/index.mjs +4 -0
  15. package/dist/functional/result/impl/index.mjs.map +1 -1
  16. package/dist/functional/result/impl/result-from-optional.d.mts +41 -0
  17. package/dist/functional/result/impl/result-from-optional.d.mts.map +1 -0
  18. package/dist/functional/result/impl/result-from-optional.mjs +24 -0
  19. package/dist/functional/result/impl/result-from-optional.mjs.map +1 -0
  20. package/dist/functional/result/impl/result-match.d.mts +47 -0
  21. package/dist/functional/result/impl/result-match.d.mts.map +1 -0
  22. package/dist/functional/result/impl/result-match.mjs +24 -0
  23. package/dist/functional/result/impl/result-match.mjs.map +1 -0
  24. package/dist/functional/result/impl/result-safe-try.d.mts +51 -0
  25. package/dist/functional/result/impl/result-safe-try.d.mts.map +1 -0
  26. package/dist/functional/result/impl/result-safe-try.mjs +24 -0
  27. package/dist/functional/result/impl/result-safe-try.mjs.map +1 -0
  28. package/dist/functional/result/impl/result-safe-unwrap.d.mts +36 -0
  29. package/dist/functional/result/impl/result-safe-unwrap.d.mts.map +1 -0
  30. package/dist/functional/result/impl/result-safe-unwrap.mjs +14 -0
  31. package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -0
  32. package/dist/object/object.d.mts +113 -0
  33. package/dist/object/object.d.mts.map +1 -1
  34. package/dist/object/object.mjs +29 -0
  35. package/dist/object/object.mjs.map +1 -1
  36. package/dist/others/debounce-function.d.mts.map +1 -1
  37. package/dist/others/debounce-function.mjs.map +1 -1
  38. package/dist/others/fast-deep-equal.d.mts.map +1 -1
  39. package/dist/others/fast-deep-equal.mjs +1 -1
  40. package/dist/others/fast-deep-equal.mjs.map +1 -1
  41. package/package.json +9 -9
  42. package/src/array/impl/array-utils-modification.test.mts +3 -3
  43. package/src/array/impl/array-utils-search.mts +22 -8
  44. package/src/array/impl/array-utils-shape-invariants.test.mts +3 -3
  45. package/src/array/impl/array-utils-transformation.test.mts +1 -1
  46. package/src/functional/optional/impl/index.mts +1 -0
  47. package/src/functional/optional/impl/optional-match.mts +108 -0
  48. package/src/functional/optional.test.mts +79 -0
  49. package/src/functional/result/impl/index.mts +4 -0
  50. package/src/functional/result/impl/result-from-optional.mts +80 -0
  51. package/src/functional/result/impl/result-match.mts +108 -0
  52. package/src/functional/result/impl/result-safe-try.mts +110 -0
  53. package/src/functional/result/impl/result-safe-unwrap.mts +50 -0
  54. package/src/functional/result.test.mts +331 -0
  55. package/src/guard/is-error.test.mts +7 -7
  56. package/src/object/object.mts +187 -0
  57. package/src/object/object.test.mts +120 -1
  58. package/src/others/debounce-function.mts +5 -1
  59. package/src/others/fast-deep-equal.mts +9 -2
@@ -0,0 +1,14 @@
1
+ import { isErr } from './result-is-err.mjs';
2
+
3
+ function* safeUnwrap(result) {
4
+ if (isErr(result)) {
5
+ yield result;
6
+ throw new Error(
7
+ "`safeUnwrap()` generator was resumed after yielding an `Err`; it must only be used via `yield*` inside `safeTry()`"
8
+ );
9
+ }
10
+ return result.value;
11
+ }
12
+
13
+ export { safeUnwrap };
14
+ //# sourceMappingURL=result-safe-unwrap.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-safe-unwrap.mjs","sources":["../../../../src/functional/result/impl/result-safe-unwrap.mts"],"sourcesContent":["import { type UnknownResult } from '../result.mjs';\nimport { isErr } from './result-is-err.mjs';\nimport { type NarrowToErr, type UnwrapOk } from './types.mjs';\n\n/**\n * Unwraps a `Result` inside a {@link Result.safeTry} generator body via\n * `yield*`, emulating Rust's `?` operator.\n *\n * If the `Result` is `Ok`, the `yield*` expression evaluates to the contained\n * value and execution continues. If it is `Err`, the error is yielded to\n * {@link Result.safeTry}, which returns it immediately — the rest of the\n * generator body never runs.\n *\n * This generator must only be delegated to (`yield*`) inside a\n * {@link Result.safeTry} body; resuming it after it has yielded an `Err`\n * throws.\n *\n * @example\n *\n * ```ts\n * const result = Result.safeTry(function* () {\n * const x = yield* Result.safeUnwrap(Result.ok(2));\n *\n * const y = yield* Result.safeUnwrap(Result.ok(3));\n *\n * return Result.ok(x + y);\n * });\n *\n * assert.deepStrictEqual(result, Result.ok(5));\n * ```\n *\n * @template R The input `UnknownResult` type.\n * @param result The `Result` to unwrap.\n * @returns A generator that yields the `Err` (if any) and returns the `Ok`\n * value.\n */\nexport function* safeUnwrap<R extends UnknownResult>(\n result: R,\n): Generator<NarrowToErr<R>, UnwrapOk<R>, unknown> {\n if (isErr(result)) {\n yield result;\n\n throw new Error(\n '`safeUnwrap()` generator was resumed after yielding an `Err`; it must only be used via `yield*` inside `safeTry()`',\n );\n }\n\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n return result.value as UnwrapOk<R>;\n}\n"],"names":[],"mappings":";;AAoCO,UAAU,WACf,MAAA,EACiD;AACjD,EAAA,IAAI,KAAA,CAAM,MAAM,CAAA,EAAG;AACjB,IAAA,MAAM,MAAA;AAEN,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KACF;AAAA,EACF;AAGA,EAAA,OAAO,MAAA,CAAO,KAAA;AAChB;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { type ArrayElement, type Decrement, type DeepOmit, type DeepPick, type IsFixedLengthList, type IsUnion, type List, type ReadonlyRecord, type RelaxedExclude, type RelaxedOmit, type RelaxedPick, type StrictOmit, type StrictPick, type ToString, type TypeEq, type UnknownRecord } from 'ts-type-forge';
2
+ import { Optional } from '../functional/index.mjs';
2
3
  /**
3
4
  * A collection of type-safe object utility functions providing functional
4
5
  * programming patterns for object manipulation, including pick, omit, shallow
@@ -235,6 +236,101 @@ export declare namespace Obj {
235
236
  * @returns A new record with the same keys as `record` and the mapped values
236
237
  */
237
238
  const map: <const R extends UnknownRecord, V2>(record: R, mapFn: (value: R[keyof R], key: TsDataForgeInternals.MappedRecordKey<R>) => V2) => TsDataForgeInternals.MappedRecord<R, V2>;
239
+ /**
240
+ * Keeps the entries whose value the predicate accepts, leaving the values
241
+ * themselves untouched.
242
+ *
243
+ * **Type Behavior**: the surviving keys are the keys of the source record,
244
+ * made optional — the predicate may reject any of them. A record keyed by an
245
+ * index signature stays total instead, because it names no specific key that
246
+ * could go missing.
247
+ *
248
+ * Passing a type guard narrows the value type of the result, which is what
249
+ * `Object.fromEntries(Object.entries(record).filter(guard))` loses.
250
+ *
251
+ * **Key handling**: keys reach the callback the way `Object.entries` yields
252
+ * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are
253
+ * not enumerated by `Object.entries`; they are dropped from both the result
254
+ * and its type.
255
+ *
256
+ * @example
257
+ *
258
+ * <!-- doc:embed:jsdoc:example:./samples/src/object/filter-example.mts -->
259
+ *
260
+ * ```ts
261
+ * const scores = { alice: 1, bob: 2 } as const;
262
+ *
263
+ * const passing = Obj.filter(scores, (value) => value > 1);
264
+ *
265
+ * assert.deepStrictEqual(passing, { bob: 2 });
266
+ *
267
+ * // The key is available as the second argument.
268
+ * const notAlice = Obj.filter(scores, (_value, key) => key !== 'alice');
269
+ *
270
+ * assert.deepStrictEqual(notAlice, { bob: 2 });
271
+ *
272
+ * // A type guard narrows the value type of the result.
273
+ * const mixed: UnknownRecord = { a: 1, b: 'x' } as const;
274
+ *
275
+ * const strings = Obj.filter(mixed, isString);
276
+ *
277
+ * assert.deepStrictEqual(strings, { b: 'x' });
278
+ * ```
279
+ *
280
+ * <!-- /doc:embed:jsdoc:example:./samples/src/object/filter-example.mts -->
281
+ *
282
+ * @template R - The type of the source record
283
+ * @template V2 - The type the guard narrows values to
284
+ * @param record - The record whose entries are filtered
285
+ * @param predicate - Called once per own enumerable string key, with the
286
+ * value and the key
287
+ * @returns A new record holding only the accepted entries
288
+ */
289
+ function filter<const R extends UnknownRecord, V2 extends R[keyof R]>(record: R, predicate: (value: R[keyof R], key: TsDataForgeInternals.MappedRecordKey<R>) => value is V2): TsDataForgeInternals.FilteredRecord<TsDataForgeInternals.MappedRecord<R, V2>>;
290
+ function filter<const R extends UnknownRecord>(record: R, predicate: (value: R[keyof R], key: TsDataForgeInternals.MappedRecordKey<R>) => boolean): TsDataForgeInternals.FilteredRecord<R>;
291
+ /**
292
+ * Transforms and drops entries in one pass: the callback returns
293
+ * `Optional.some(value)` to keep an entry with a new value, or
294
+ * `Optional.none` to drop it.
295
+ *
296
+ * **Type Behavior**: as with {@link filter}, the surviving keys are the keys
297
+ * of the source record made optional, and a record keyed by an index
298
+ * signature stays total. Unlike {@link filter}, every kept value takes the
299
+ * type the callback returns.
300
+ *
301
+ * `Optional` rather than `undefined` marks the dropped entries, so a record
302
+ * whose values are legitimately `undefined` stays expressible.
303
+ *
304
+ * **Key handling**: keys reach the callback the way `Object.entries` yields
305
+ * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are
306
+ * not enumerated by `Object.entries`; they are dropped from both the result
307
+ * and its type.
308
+ *
309
+ * @example
310
+ *
311
+ * <!-- doc:embed:jsdoc:example:./samples/src/object/filter-map-example.mts -->
312
+ *
313
+ * ```ts
314
+ * const scores = { alice: 1, bob: 2 } as const;
315
+ *
316
+ * // `Optional.some` keeps an entry with a new value, `Optional.none` drops it.
317
+ * const labelled = Obj.filterMap(scores, (value, key) =>
318
+ * value > 1 ? Optional.some(`${key}=${value}`) : Optional.none,
319
+ * );
320
+ *
321
+ * assert.deepStrictEqual(labelled, { bob: 'bob=2' });
322
+ * ```
323
+ *
324
+ * <!-- /doc:embed:jsdoc:example:./samples/src/object/filter-map-example.mts -->
325
+ *
326
+ * @template R - The type of the source record
327
+ * @template V2 - The type the callback returns for the entries it keeps
328
+ * @param record - The record whose entries are transformed and filtered
329
+ * @param mapFn - Called once per own enumerable string key, with the value
330
+ * and the key
331
+ * @returns A new record holding only the kept entries, with mapped values
332
+ */
333
+ const filterMap: <const R extends UnknownRecord, V2>(record: R, mapFn: (value: R[keyof R], key: TsDataForgeInternals.MappedRecordKey<R>) => Optional<V2>) => TsDataForgeInternals.FilteredRecord<TsDataForgeInternals.MappedRecord<R, V2>>;
238
334
  /**
239
335
  * Merges multiple records into a single record using `Object.assign`.
240
336
  * Later records override properties from earlier records with the same key.
@@ -356,6 +452,23 @@ declare namespace TsDataForgeInternals {
356
452
  type MappedRecord<R, V2> = Readonly<{
357
453
  [K in keyof R as K extends symbol ? never : K]: V2;
358
454
  }>;
455
+ /** `R` without the symbol keys `Object.entries` never visits. */
456
+ type StringKeyedRecord<R> = Readonly<{
457
+ [K in keyof R as K extends symbol ? never : K]: R[K];
458
+ }>;
459
+ /**
460
+ * The result of dropping entries from `R`: symbol keys go away, and the
461
+ * remaining keys become optional because a predicate may reject any of them.
462
+ *
463
+ * A record keyed by an index signature stays total instead. It names no
464
+ * specific key that could go missing, and `noUncheckedIndexedAccess` already
465
+ * adds `| undefined` on access, so making it `Partial` would add nothing and
466
+ * would only stop the result from being assignable back to the record type it
467
+ * came from.
468
+ */
469
+ type FilteredRecord<R> = string extends keyof R ? StringKeyedRecord<R> : number extends keyof R ? StringKeyedRecord<R> : Readonly<{
470
+ [K in keyof R as K extends symbol ? never : K]?: R[K];
471
+ }>;
359
472
  /**
360
473
  * Merges two object types where keys in B override keys in A, preserving optional modifiers.
361
474
  *
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.mts","sourceRoot":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E9B,iBAAiB,CAAC,OAAO,CAAC,SAAS,KAAK,GACpC,YAAY,CAAC,OAAO,CAAC,GACrB,OAAO,SAAS,SAAS;QACrB,MAAM,KAAK,SAAS,aAAa;QACjC,GAAG,MAAM,IAAI,SAAS,SAAS,aAAa,EAAE;KAC/C,GACD,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,GACpC,GAAG,CAAC;CACb"}
@@ -36,6 +36,7 @@ import '../number/num.mjs';
36
36
  import '../number/refined-number-utils.mjs';
37
37
  import { hasKey } from '../guard/has-key.mjs';
38
38
  import { isRecord } from '../guard/is-record.mjs';
39
+ import { isSome } from '../functional/optional/impl/optional-is-some.mjs';
39
40
  import '@sindresorhus/is';
40
41
  import { isNonEmpty } from '../array/impl/array-utils-length-bounded-array-guard.mjs';
41
42
  import '../collections/imap-mapped.mjs';
@@ -114,6 +115,34 @@ var Obj;
114
115
  )
115
116
  );
116
117
  };
118
+ function filter(record, predicate) {
119
+ const predicateWidened = predicate;
120
+ return (
121
+ // `Object.entries` enumerates exactly the own enumerable string keys of
122
+ // `record`, and filtering only ever removes entries, so the result has a
123
+ // subset of those keys — which is what `FilteredRecord` claims.
124
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
125
+ Object.fromEntries(
126
+ Object.entries(record).filter(([k, v]) => predicateWidened(v, k))
127
+ )
128
+ );
129
+ }
130
+ Obj2.filter = filter;
131
+ Obj2.filterMap = (record, mapFn) => {
132
+ const mapFnWidened = mapFn;
133
+ return (
134
+ // `Object.entries` enumerates exactly the own enumerable string keys of
135
+ // `record`, and this only ever drops entries or replaces their values, so
136
+ // the result has a subset of those keys with `V2` values.
137
+ // eslint-disable-next-line total-functions/no-unsafe-type-assertion
138
+ Object.fromEntries(
139
+ Object.entries(record).flatMap(([k, v]) => {
140
+ const mapped = mapFnWidened(v, k);
141
+ return isSome(mapped) ? [[k, mapped.value]] : [];
142
+ })
143
+ )
144
+ );
145
+ };
117
146
  Obj2.merge = (...records) => (
118
147
  // eslint-disable-next-line total-functions/no-unsafe-type-assertion
119
148
  Object.fromEntries(records.flatMap((r) => Object.entries(r)))
@@ -1 +1 @@
1
- {"version":3,"file":"object.mjs","sources":["../../src/object/object.mts"],"sourcesContent":["import {\n type ArrayElement,\n type Decrement,\n type DeepOmit,\n type DeepPick,\n type IsFixedLengthList,\n type IsUnion,\n type List,\n type ReadonlyRecord,\n type RelaxedExclude,\n type RelaxedOmit,\n type RelaxedPick,\n type StrictOmit,\n type StrictPick,\n type ToString,\n type TypeEq,\n type UnknownRecord,\n} from 'ts-type-forge';\nimport { Arr } from '../array/index.mjs';\nimport { hasKey, isRecord } from '../guard/index.mjs';\n\n/**\n * A collection of type-safe object utility functions providing functional\n * programming patterns for object manipulation, including pick, omit, shallow\n * equality checks, and more.\n *\n * All functions maintain TypeScript type safety and support both direct and\n * curried usage patterns for better composition with pipe operations.\n */\nexport namespace Obj {\n /**\n * Performs a shallow equality check on two records using a configurable\n * equality function. Verifies that both records have the same number of\n * entries and that for every key in the first record, the corresponding value\n * passes the equality test with the value in the second record.\n *\n * @example\n *\n * ```ts\n * const obj1 = { name: 'Alice', age: 30 } as const;\n *\n * const obj2 = { name: 'Alice', age: 30 } as const;\n *\n * const obj3 = { name: 'Alice', age: 31 } as const;\n *\n * assert.isTrue(Obj.shallowEq(obj1, obj2));\n *\n * assert.isFalse(Obj.shallowEq(obj1, obj3));\n *\n * // Custom equality function\n * const obj4 = { value: 1 } as const;\n *\n * const obj5 = { value: 1.00001 } as const;\n *\n * const closeEnough = (a: unknown, b: unknown): boolean => {\n * if (typeof a === 'number' && typeof b === 'number') {\n * return Math.abs(a - b) < 0.001;\n * }\n *\n * return Object.is(a, b);\n * };\n *\n * assert.isTrue(Obj.shallowEq(obj4, obj5, closeEnough));\n * ```\n *\n * @param a - The first record to compare\n * @param b - The second record to compare\n * @param eq - Optional equality function (defaults to Object.is for strict\n * equality)\n * @returns `true` if the records are shallowly equal according to the\n * equality function, `false` otherwise\n */\n export const shallowEq = (\n a: UnknownRecord,\n b: UnknownRecord,\n eq: (x: unknown, y: unknown) => boolean = Object.is,\n ): boolean => {\n const aEntries = Object.entries(a);\n\n const bEntries = Object.entries(b);\n\n if (aEntries.length !== bEntries.length) return false;\n\n return aEntries.every(([k, v]) => eq(b[k], v));\n };\n\n /**\n * Creates a new record that contains only the specified keys from the source\n * record. This function supports both direct usage and curried form for\n * functional composition.\n *\n * **Type Safety**: Only keys that exist in the source record type are\n * allowed, preventing runtime errors from accessing non-existent properties.\n *\n * @example\n *\n * ```ts\n * const user = {\n * id: 1,\n * name: 'Bob',\n * email: 'bob@example.com',\n * password: 'secret',\n * role: 'admin',\n * } as const;\n *\n * // Direct usage\n * const publicInfo = Obj.pick(user, ['id', 'name', 'role']);\n *\n * assert.deepStrictEqual(publicInfo, {\n * id: 1,\n * name: 'Bob',\n * role: 'admin',\n * });\n *\n * // Curried usage with pipe\n * const nameAndEmail = pipe(user).map(Obj.pick(['name', 'email'])).value;\n *\n * assert.deepStrictEqual(nameAndEmail, {\n * name: 'Bob',\n * email: 'bob@example.com',\n * });\n * ```\n *\n * @template R - The type of the input record\n * @template Keys - The readonly array type of keys to pick from the record\n * @param record - The source record to pick properties from\n * @param keys - A readonly array of keys to include in the result\n * @returns A new record containing only the specified keys and their values\n */\n export function pick<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(record: R, keys: Keys): StrictPick<R, ArrayElement<Keys>>;\n\n // Curried version\n export function pick<const Keys extends readonly PropertyKey[]>(\n keys: Keys,\n ): <const R extends UnknownRecord>(\n record: R,\n ) => RelaxedPick<R, ArrayElement<Keys>>;\n\n export function pick<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(\n ...args: readonly [record: R, keys: Keys] | readonly [keys: Keys]\n ):\n | StrictPick<R, ArrayElement<Keys>>\n | ((record: R) => RelaxedPick<R, ArrayElement<Keys>>) {\n switch (args.length) {\n case 2: {\n const [record, keys] = args;\n\n const keysSet = new Set<keyof R>(keys);\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, _v]) => keysSet.has(k)),\n ) as never\n );\n }\n\n case 1: {\n const [keys] = args;\n\n return (record: R) => pick(record, keys);\n }\n }\n }\n\n /**\n * Creates a new record that excludes the specified keys from the source\n * record. This function supports both direct usage and curried form for\n * functional composition.\n *\n * **Type Safety**: Only keys that exist in the source record type are\n * allowed, and the return type precisely reflects which properties remain\n * after omission.\n *\n * @example\n *\n * ```ts\n * const user = {\n * id: 1,\n * name: 'Charlie',\n * email: 'charlie@example.com',\n * password: 'secret123',\n * internalNote: 'VIP customer',\n * } as const;\n *\n * // Direct usage - remove sensitive fields\n * const safeUser = Obj.omit(user, ['password', 'internalNote']);\n *\n * assert.deepStrictEqual(safeUser, {\n * id: 1,\n * name: 'Charlie',\n * email: 'charlie@example.com',\n * });\n *\n * // Curried usage with pipe\n * const withoutEmail = pipe(user).map(Obj.omit(['email', 'password'])).value;\n *\n * assert.deepStrictEqual(withoutEmail, {\n * id: 1,\n * name: 'Charlie',\n * internalNote: 'VIP customer',\n * });\n * ```\n *\n * @template R - The type of the input record\n * @template Keys - The readonly array type of keys to omit from the record\n * @param record - The source record to omit properties from\n * @param keys - A readonly array of keys to exclude from the result\n * @returns A new record containing all properties except the specified keys\n */\n export function omit<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(record: R, keys: Keys): StrictOmit<R, ArrayElement<Keys>>;\n\n // Curried version\n export function omit<const Keys extends readonly PropertyKey[]>(\n keys: Keys,\n ): <const R extends UnknownRecord>(\n record: R,\n ) => RelaxedOmit<R, ArrayElement<Keys>>;\n\n export function omit<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(\n ...args:\n readonly [record: R, keys: Keys] | readonly [keys: readonly PropertyKey[]]\n ):\n | StrictOmit<R, ArrayElement<Keys>>\n | ((record: R) => StrictOmit<R, ArrayElement<Keys>>) {\n switch (args.length) {\n case 2: {\n const [record, keys] = args;\n\n const keysSet = new Set<keyof R>(keys);\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, _v]) => !keysSet.has(k)),\n ) as never\n );\n }\n\n case 1: {\n const [keys] = args;\n\n return <R2 extends UnknownRecord>(record: R2) => {\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const result = omit(\n record,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n keys as readonly (keyof R2)[],\n ) as RelaxedOmit<R2, ArrayElement<Keys>>;\n\n return result;\n };\n }\n }\n }\n\n /**\n * Creates an object from an array of key-value pairs with precise TypeScript\n * typing. This is a type-safe wrapper around `Object.fromEntries` that\n * provides better type inference and compile-time guarantees about the\n * resulting object structure.\n *\n * **Type Behavior**:\n *\n * - When entries is a fixed-length tuple, the exact object type is inferred\n * - When entries has dynamic length with union key types, `Partial` is applied\n * to prevent incorrect assumptions about which keys will be present\n *\n * @example\n *\n * ```ts\n * // Fixed-length tuple - exact type inferred\n * const entries1 = [\n * ['name', 'David'],\n * ['age', 25],\n * ['active', true],\n * ] as const;\n *\n * const obj1 = Obj.fromEntries(entries1);\n *\n * assert.deepStrictEqual(obj1, {\n * name: 'David',\n * age: 25,\n * active: true,\n * });\n *\n * // Dynamic length array - Partial type applied\n * const dynamicEntries: readonly (readonly ['x' | 'y', number])[] = [\n * ['x', 10],\n * ['y', 20],\n * ] as const;\n *\n * const obj2 = Obj.fromEntries(dynamicEntries);\n *\n * assert.deepStrictEqual(obj2, { x: 10, y: 20 });\n * ```\n *\n * @template Entries - The readonly array type of key-value entry tuples\n * @param entries - An array of readonly key-value entry tuples `[key, value]`\n * @returns An object created from the entries with precise typing\n */\n export const fromEntries = <\n const Entries extends readonly (readonly [PropertyKey, unknown])[],\n >(\n entries: Entries,\n ): IsFixedLengthList<Entries> extends true\n ? TsDataForgeInternals.EntriesToObject<Entries>\n : TsDataForgeInternals.PartialIfKeyIsUnion<\n TsDataForgeInternals.KeysOfEntries<Entries>,\n ReadonlyRecord<\n TsDataForgeInternals.KeysOfEntries<Entries>,\n TsDataForgeInternals.ValuesOfEntries<Entries>\n >\n > =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(entries) as never;\n\n /**\n * Transforms every value of a record, leaving the key set untouched.\n *\n * **Type Behavior**: the result is a mapped type over `keyof R`, so the keys\n * — and their optional modifiers — survive verbatim:\n * `{ a: number; b?: number }` maps to `{ a: V2; b?: V2 }`, and a record with\n * an index signature stays total rather than becoming `Partial`.\n *\n * This is what `Object.fromEntries(Object.entries(record).map(...))` cannot\n * express: an entries array carries no evidence that it still covers every\n * key of the record it came from, so its element type is all the return type\n * can be built from. Going through a mapped type instead states the\n * invariant that a value-only transform preserves the key set.\n *\n * **Key handling**: keys reach the callback the way `Object.entries` yields\n * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are\n * not enumerated by `Object.entries`; they are dropped from both the result\n * and its type.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/map-example.mts -->\n *\n * ```ts\n * const scores = { alice: 1, bob: 2 } as const;\n *\n * const doubled = Obj.map(scores, (value) => value * 2);\n *\n * assert.deepStrictEqual(doubled, { alice: 2, bob: 4 });\n *\n * // The key is available as the second argument.\n * const labelled = Obj.map(scores, (value, key) => `${key}=${value}`);\n *\n * assert.deepStrictEqual(labelled, { alice: 'alice=1', bob: 'bob=2' });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/map-example.mts -->\n *\n * @template R - The type of the source record\n * @template V2 - The type the callback returns for every key\n * @param record - The record whose values are transformed\n * @param mapFn - Called once per own enumerable string key, with the value\n * and the key\n * @returns A new record with the same keys as `record` and the mapped values\n */\n export const map = <const R extends UnknownRecord, V2>(\n record: R,\n mapFn: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => V2,\n ): TsDataForgeInternals.MappedRecord<R, V2> => {\n // `Object.entries` erases both the key and the value type of `R`, so the\n // callback is widened once here instead of asserting on every entry.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const mapFnWidened = mapFn as (value: unknown, key: string) => V2;\n\n return (\n // `Object.entries` enumerates exactly the own enumerable string keys of\n // `record`, and nothing here adds or removes an entry, so the result has\n // the key set `MappedRecord` claims.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).map(\n ([k, v]) => [k, mapFnWidened(v, k)] as const,\n ),\n ) as never\n );\n };\n\n /**\n * Merges multiple records into a single record using `Object.assign`.\n * Later records override properties from earlier records with the same key.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/merge-example.mts -->\n *\n * ```ts\n * const a = { a: 0, b: 0 } as const;\n *\n * const b = { b: 1, c: 0 } as const;\n *\n * const result = Obj.merge(a, b);\n *\n * assert.deepStrictEqual(result, { a: 0, b: 1, c: 0 });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/merge-example.mts -->\n *\n * @param records - The records to merge\n * @returns A new record with all properties merged\n */\n export const merge = <const Records extends readonly UnknownRecord[]>(\n ...records: Records\n ): TsDataForgeInternals.MergeAll<Records> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(records.flatMap((r) => Object.entries(r))) as never;\n\n /**\n * Deeply picks a nested property from an object along the specified key path.\n * Supports both direct and curried usage.\n *\n * @example\n *\n * ```ts\n * const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;\n *\n * // Direct usage\n * const result = Obj.deepPick(data, ['a', 'b', 'c']);\n *\n * assert.deepStrictEqual(result, { a: { b: { c: 1 } } });\n *\n * // Curried usage with pipe\n * const pickAB = Obj.deepPick(['a', 'b']);\n *\n * const result2 = pipe(data).map(pickAB).value;\n *\n * assert.deepStrictEqual(result2, { a: { b: { c: 1, d: 2 } } });\n * ```\n *\n * @template R - The type of the input record\n * @template Path - The key path tuple\n * @param record - The source record\n * @param path - A readonly tuple of keys representing the nested path\n * @returns A new record containing only the nested property at the path\n */\n export function deepPick<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(record: R, path: Path): DeepPick<R, Path>;\n\n // Curried version\n export function deepPick<const Path extends readonly (string | number)[]>(\n path: Path,\n ): <const R extends UnknownRecord>(record: R) => DeepPick<R, Path>;\n\n export function deepPick<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(\n ...args: readonly [record: R, path: Path] | readonly [path: Path]\n ): DeepPick<R, Path> | ((record: R) => DeepPick<R, Path>) {\n switch (args.length) {\n case 2: {\n const [record, path] = args;\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n deepPickImpl(record, path) as never\n );\n }\n\n case 1: {\n const [path] = args;\n\n return (record: R) => deepPick(record, path);\n }\n }\n }\n\n /**\n * Deeply omits a nested property from an object along the specified key path.\n * Supports both direct and curried usage.\n *\n * @example\n *\n * ```ts\n * const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;\n *\n * // Direct usage\n * const result = Obj.deepOmit(data, ['a', 'b', 'c']);\n *\n * assert.deepStrictEqual(result, { a: { b: { d: 2 }, e: 3 }, f: 4 });\n *\n * // Curried usage with pipe\n * const omitAB = Obj.deepOmit(['a', 'b']);\n *\n * const result2 = pipe(data).map(omitAB).value;\n *\n * assert.deepStrictEqual(result2, { a: { e: 3 }, f: 4 });\n * ```\n *\n * @template R - The type of the input record\n * @template Path - The key path tuple\n * @param record - The source record\n * @param path - A readonly tuple of keys representing the nested path to omit\n * @returns A new record with the nested property at the path removed\n */\n export function deepOmit<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(record: R, path: Path): DeepOmit<R, Path>;\n\n // Curried version\n export function deepOmit<const Path extends readonly (string | number)[]>(\n path: Path,\n ): <const R extends UnknownRecord>(record: R) => DeepOmit<R, Path>;\n\n export function deepOmit<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(\n ...args: readonly [record: R, path: Path] | readonly [path: Path]\n ): DeepOmit<R, Path> | ((record: R) => DeepOmit<R, Path>) {\n switch (args.length) {\n case 2: {\n const [record, path] = args;\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n deepOmitImpl(record, path) as never\n );\n }\n\n case 1: {\n const [path] = args;\n\n return (record: R) => deepOmit(record, path);\n }\n }\n }\n}\n\nconst deepPickImpl = (\n record: UnknownRecord,\n path: readonly (string | number)[],\n): UnknownRecord => {\n if (!Arr.isNonEmpty(path)) return record;\n\n const head = path[0];\n\n if (!hasKey(record, head)) return {};\n\n const value = record[head];\n\n const tail = path.slice(1);\n\n if (!Arr.isNonEmpty(tail)) return { [head]: value };\n\n if (!isRecord(value)) return { [head]: {} };\n\n return {\n [head]: deepPickImpl(value, tail),\n };\n};\n\nconst deepOmitImpl = (\n record: UnknownRecord,\n path: readonly (string | number)[],\n): UnknownRecord => {\n if (!Arr.isNonEmpty(path)) return record;\n\n const head = path[0];\n\n if (!hasKey(record, head)) return record;\n\n const tail = path.slice(1);\n\n if (!Arr.isNonEmpty(tail)) {\n return Object.fromEntries(\n Object.entries(record).filter(([k]) => k !== head),\n );\n }\n\n const value = record[head];\n\n if (!isRecord(value)) return record;\n\n return {\n ...record,\n [head]: deepOmitImpl(value, tail),\n };\n};\n\n/**\n * @internal\n * Internal type utilities for the Obj module.\n */\ndeclare namespace TsDataForgeInternals {\n type RecursionLimit = 20;\n\n /** - `[['x', 1], ['y', 3]]` -> `{ x: 1, y: 3 }` */\n export type EntriesToObject<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n > = Readonly<EntriesToObjectImpl<{}, Entries>>;\n\n /** @internal */\n type EntriesToObjectImpl<\n R,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > =\n TypeEq<Entries['length'], 0> extends true\n ? R\n : EntriesToObjectImpl<\n R & ReadonlyRecord<Entries[0][0], Entries[0][1]>,\n List.Tail<Entries>\n >;\n\n /**\n * - `['x' | 'y' | 'z', number][]]` -> `'x' | 'y' | 'z'`\n * - `[['a' | 'b' | 'c', number], ...['x' | 'y' | 'z', number][]]` -> `'a' |\n * 'b' | 'c' | 'x' | 'y' | 'z'`\n *\n * @note To handle the second example above, recursion needs to be performed on infinite-length Entries,\n * but since the timing to stop cannot be determined, a recursion limit is set.\n */\n export type KeysOfEntries<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > = KeysOfEntriesImpl<never, Entries, RecursionLimit>;\n\n type KeysOfEntriesImpl<\n K,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n RemainingNumRecursions extends number,\n > =\n TypeEq<RemainingNumRecursions, 0> extends true\n ? K\n : TypeEq<Entries['length'], 0> extends true\n ? K\n : KeysOfEntriesImpl<\n K | Entries[0][0],\n List.Tail<Entries>,\n Decrement<RemainingNumRecursions>\n >;\n\n export type ValuesOfEntries<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > = ValuesOfEntriesImpl<never, Entries, RecursionLimit>;\n\n type ValuesOfEntriesImpl<\n K,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n RemainingNumRecursions extends number,\n > =\n TypeEq<RemainingNumRecursions, 0> extends true\n ? K\n : TypeEq<Entries['length'], 0> extends true\n ? K\n : ValuesOfEntriesImpl<\n K | Entries[0][1],\n List.Tail<Entries>,\n Decrement<RemainingNumRecursions>\n >;\n\n export type PartialIfKeyIsUnion<K, T> =\n IsUnion<K> extends true ? Partial<T> : T;\n\n /**\n * The keys `Object.entries` yields for `R`: symbol keys are not enumerated,\n * and a numeric key `1` arrives as the string `'1'`.\n */\n export type MappedRecordKey<R> = ToString<RelaxedExclude<keyof R, symbol>>;\n\n /**\n * `R` with every value replaced by `V2`. Homomorphic over `keyof R`, so\n * optional modifiers and index signatures are preserved; the key remapping\n * drops the symbol keys that `Object.entries` would not have visited.\n */\n export type MappedRecord<R, V2> = Readonly<{\n [K in keyof R as K extends symbol ? never : K]: V2;\n }>;\n\n /**\n * Merges two object types where keys in B override keys in A, preserving optional modifiers.\n *\n * This implementation uses a sophisticated technique to preserve optional property modifiers (`?`)\n * during the merge operation, which would otherwise be lost in a naive mapped type implementation.\n *\n * ## Core Technique: Optional Property Detection\n *\n * Uses `{} extends Pick<T, K>` to determine if a property is optional:\n * - **Required property**: `Pick<T, 'x'>` = `{ x: number }` → `{}` does NOT extend it (false)\n * - **Optional property**: `Pick<T, 'y'>` = `{ y?: string }` → `{}` DOES extend it (true)\n *\n * This works because `{}` (empty object) is assignable to objects with only optional properties\n * but not to objects with required properties.\n *\n * ## Implementation Strategy\n *\n * The type is constructed as an intersection of five mapped types:\n *\n * 1. **Required properties from B** - Properties in B that are required (override A completely)\n * 2. **Optional properties from B (not in A)** - New optional properties from B\n * 3. **Optional properties from B (in A)** - Union of A[K] | B[K] to preserve both possibilities\n * 4. **Required properties only in A** - Properties in A but not in B that are required\n * 5. **Optional properties only in A** - Properties in A but not in B that are optional (with `?` modifier)\n *\n * Finally, the intersection is flattened using an optional-preserving identity mapping that\n * re-applies the optional detection logic to maintain the `?` modifiers in the final type.\n *\n * @example\n * ```ts\n * type A = Readonly<{ x: number; y?: string }>;\n *\n * type B = Readonly<{ y?: number; z?: boolean }>;\n *\n * type Result = MergeTwo<A, B>;\n * // Result: Readonly<{ x: number; y?: string | number; z?: boolean }>\n * ```\n */\n // transformer-ignore-next-line\n type MergeTwo<A extends UnknownRecord, B extends UnknownRecord> = {\n // 1. Required properties from B (override A completely)\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n readonly [K in keyof B as {} extends StrictPick<B, K> ? never : K]: B[K];\n } & {\n // 2. Optional properties from B that are NOT in A\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in keyof B as {} extends StrictPick<B, K>\n ? K extends keyof A\n ? never\n : K\n : never\n ]?: B[K];\n } & {\n // 3. Optional properties from B that ARE in A (create union)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in keyof B as {} extends StrictPick<B, K>\n ? K extends keyof A\n ? K\n : never\n : never\n ]?: K extends keyof A ? A[K] | B[K] : never;\n } & {\n // 4. Required properties only in A (not overridden by B)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in RelaxedExclude<keyof A, keyof B> as {} extends StrictPick<A, K>\n ? never\n : K\n ]: A[K];\n } & {\n // 5. Optional properties only in A (not overridden by B)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in RelaxedExclude<keyof A, keyof B> as {} extends StrictPick<A, K>\n ? K\n : never\n ]?: A[K];\n } extends infer O\n ? Readonly<\n {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n [K in keyof O as {} extends StrictPick<O, K> ? never : K]: O[K];\n } & {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n [K in keyof O as {} extends StrictPick<O, K> ? K : never]?: O[K];\n }\n >\n : never;\n\n /** Sequentially merges a tuple of object types from left to right. */\n export type MergeAll<\n Records extends readonly UnknownRecord[],\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n Acc extends UnknownRecord = {},\n > =\n IsFixedLengthList<Records> extends false\n ? ArrayElement<Records>\n : Records extends readonly [\n infer First extends UnknownRecord,\n ...infer Rest extends readonly UnknownRecord[],\n ]\n ? MergeAll<Rest, MergeTwo<Acc, First>>\n : Acc;\n}\n"],"names":["Obj","Arr.isNonEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,IAAU;AAAA,CAAV,CAAUA,IAAAA,KAAV;AA2CE,EAAMA,KAAA,SAAA,GAAY,CACvB,GACA,CAAA,EACA,EAAA,GAA0C,OAAO,EAAA,KACrC;AACZ,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA;AAEjC,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA;AAEjC,IAAA,IAAI,QAA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CAAA,SAAU,EAAE,CAAC,IAAI,GAAG,KAAA,EAAM;AAElD,EAAA,IAAI,CAAC,QAAA,CAAS,KAAK,CAAA,EAAG,OAAO,EAAE,CAAC,IAAI,GAAG,EAAC,EAAE;AAE1C,EAAA,OAAO;AAAA,IACL,CAAC,IAAI,GAAG,YAAA,CAAa,OAAO,IAAI;AAAA,GAClC;AACF,CAAA;AAEA,MAAM,YAAA,GAAe,CACnB,MAAA,EACA,IAAA,KACkB;AAClB,EAAA,IAAI,CAACA,UAAI,CAAW,IAAI,GAAG,OAAO,MAAA;AAElC,EAAA,MAAM,IAAA,GAAO,KAAK,CAAC,CAAA;AAEnB,EAAA,IAAI,CAAC,MAAA,CAAO,MAAA,EAAQ,IAAI,GAAG,OAAO,MAAA;AAElC,EAAA,MAAM,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,CAAC,CAAA;AAEzB,EAAA,IAAI,CAACA,UAAI,CAAW,IAAI,CAAA,EAAG;AACzB,IAAA,OAAO,MAAA,CAAO,WAAA;AAAA,MACZ,MAAA,CAAO,OAAA,CAAQ,MAAM,CAAA,CAAE,MAAA,CAAO,CAAC,CAAC,CAAC,CAAA,KAAM,CAAA,KAAM,IAAI;AAAA,KACnD;AAAA,EACF;AAEA,EAAA,MAAM,KAAA,GAAQ,OAAO,IAAI,CAAA;AAEzB,EAAA,IAAI,CAAC,QAAA,CAAS,KAAK,CAAA,EAAG,OAAO,MAAA;AAE7B,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,CAAC,IAAI,GAAG,YAAA,CAAa,OAAO,IAAI;AAAA,GAClC;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"object.mjs","sources":["../../src/object/object.mts"],"sourcesContent":["import {\n type ArrayElement,\n type Decrement,\n type DeepOmit,\n type DeepPick,\n type IsFixedLengthList,\n type IsUnion,\n type List,\n type ReadonlyRecord,\n type RelaxedExclude,\n type RelaxedOmit,\n type RelaxedPick,\n type StrictOmit,\n type StrictPick,\n type ToString,\n type TypeEq,\n type UnknownRecord,\n} from 'ts-type-forge';\nimport { Arr } from '../array/index.mjs';\nimport { Optional } from '../functional/index.mjs';\nimport { hasKey, isRecord } from '../guard/index.mjs';\n\n/**\n * A collection of type-safe object utility functions providing functional\n * programming patterns for object manipulation, including pick, omit, shallow\n * equality checks, and more.\n *\n * All functions maintain TypeScript type safety and support both direct and\n * curried usage patterns for better composition with pipe operations.\n */\nexport namespace Obj {\n /**\n * Performs a shallow equality check on two records using a configurable\n * equality function. Verifies that both records have the same number of\n * entries and that for every key in the first record, the corresponding value\n * passes the equality test with the value in the second record.\n *\n * @example\n *\n * ```ts\n * const obj1 = { name: 'Alice', age: 30 } as const;\n *\n * const obj2 = { name: 'Alice', age: 30 } as const;\n *\n * const obj3 = { name: 'Alice', age: 31 } as const;\n *\n * assert.isTrue(Obj.shallowEq(obj1, obj2));\n *\n * assert.isFalse(Obj.shallowEq(obj1, obj3));\n *\n * // Custom equality function\n * const obj4 = { value: 1 } as const;\n *\n * const obj5 = { value: 1.00001 } as const;\n *\n * const closeEnough = (a: unknown, b: unknown): boolean => {\n * if (typeof a === 'number' && typeof b === 'number') {\n * return Math.abs(a - b) < 0.001;\n * }\n *\n * return Object.is(a, b);\n * };\n *\n * assert.isTrue(Obj.shallowEq(obj4, obj5, closeEnough));\n * ```\n *\n * @param a - The first record to compare\n * @param b - The second record to compare\n * @param eq - Optional equality function (defaults to Object.is for strict\n * equality)\n * @returns `true` if the records are shallowly equal according to the\n * equality function, `false` otherwise\n */\n export const shallowEq = (\n a: UnknownRecord,\n b: UnknownRecord,\n eq: (x: unknown, y: unknown) => boolean = Object.is,\n ): boolean => {\n const aEntries = Object.entries(a);\n\n const bEntries = Object.entries(b);\n\n if (aEntries.length !== bEntries.length) return false;\n\n return aEntries.every(([k, v]) => eq(b[k], v));\n };\n\n /**\n * Creates a new record that contains only the specified keys from the source\n * record. This function supports both direct usage and curried form for\n * functional composition.\n *\n * **Type Safety**: Only keys that exist in the source record type are\n * allowed, preventing runtime errors from accessing non-existent properties.\n *\n * @example\n *\n * ```ts\n * const user = {\n * id: 1,\n * name: 'Bob',\n * email: 'bob@example.com',\n * password: 'secret',\n * role: 'admin',\n * } as const;\n *\n * // Direct usage\n * const publicInfo = Obj.pick(user, ['id', 'name', 'role']);\n *\n * assert.deepStrictEqual(publicInfo, {\n * id: 1,\n * name: 'Bob',\n * role: 'admin',\n * });\n *\n * // Curried usage with pipe\n * const nameAndEmail = pipe(user).map(Obj.pick(['name', 'email'])).value;\n *\n * assert.deepStrictEqual(nameAndEmail, {\n * name: 'Bob',\n * email: 'bob@example.com',\n * });\n * ```\n *\n * @template R - The type of the input record\n * @template Keys - The readonly array type of keys to pick from the record\n * @param record - The source record to pick properties from\n * @param keys - A readonly array of keys to include in the result\n * @returns A new record containing only the specified keys and their values\n */\n export function pick<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(record: R, keys: Keys): StrictPick<R, ArrayElement<Keys>>;\n\n // Curried version\n export function pick<const Keys extends readonly PropertyKey[]>(\n keys: Keys,\n ): <const R extends UnknownRecord>(\n record: R,\n ) => RelaxedPick<R, ArrayElement<Keys>>;\n\n export function pick<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(\n ...args: readonly [record: R, keys: Keys] | readonly [keys: Keys]\n ):\n | StrictPick<R, ArrayElement<Keys>>\n | ((record: R) => RelaxedPick<R, ArrayElement<Keys>>) {\n switch (args.length) {\n case 2: {\n const [record, keys] = args;\n\n const keysSet = new Set<keyof R>(keys);\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, _v]) => keysSet.has(k)),\n ) as never\n );\n }\n\n case 1: {\n const [keys] = args;\n\n return (record: R) => pick(record, keys);\n }\n }\n }\n\n /**\n * Creates a new record that excludes the specified keys from the source\n * record. This function supports both direct usage and curried form for\n * functional composition.\n *\n * **Type Safety**: Only keys that exist in the source record type are\n * allowed, and the return type precisely reflects which properties remain\n * after omission.\n *\n * @example\n *\n * ```ts\n * const user = {\n * id: 1,\n * name: 'Charlie',\n * email: 'charlie@example.com',\n * password: 'secret123',\n * internalNote: 'VIP customer',\n * } as const;\n *\n * // Direct usage - remove sensitive fields\n * const safeUser = Obj.omit(user, ['password', 'internalNote']);\n *\n * assert.deepStrictEqual(safeUser, {\n * id: 1,\n * name: 'Charlie',\n * email: 'charlie@example.com',\n * });\n *\n * // Curried usage with pipe\n * const withoutEmail = pipe(user).map(Obj.omit(['email', 'password'])).value;\n *\n * assert.deepStrictEqual(withoutEmail, {\n * id: 1,\n * name: 'Charlie',\n * internalNote: 'VIP customer',\n * });\n * ```\n *\n * @template R - The type of the input record\n * @template Keys - The readonly array type of keys to omit from the record\n * @param record - The source record to omit properties from\n * @param keys - A readonly array of keys to exclude from the result\n * @returns A new record containing all properties except the specified keys\n */\n export function omit<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(record: R, keys: Keys): StrictOmit<R, ArrayElement<Keys>>;\n\n // Curried version\n export function omit<const Keys extends readonly PropertyKey[]>(\n keys: Keys,\n ): <const R extends UnknownRecord>(\n record: R,\n ) => RelaxedOmit<R, ArrayElement<Keys>>;\n\n export function omit<\n const R extends UnknownRecord,\n const Keys extends readonly (keyof R)[],\n >(\n ...args:\n readonly [record: R, keys: Keys] | readonly [keys: readonly PropertyKey[]]\n ):\n | StrictOmit<R, ArrayElement<Keys>>\n | ((record: R) => StrictOmit<R, ArrayElement<Keys>>) {\n switch (args.length) {\n case 2: {\n const [record, keys] = args;\n\n const keysSet = new Set<keyof R>(keys);\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, _v]) => !keysSet.has(k)),\n ) as never\n );\n }\n\n case 1: {\n const [keys] = args;\n\n return <R2 extends UnknownRecord>(record: R2) => {\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const result = omit(\n record,\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n keys as readonly (keyof R2)[],\n ) as RelaxedOmit<R2, ArrayElement<Keys>>;\n\n return result;\n };\n }\n }\n }\n\n /**\n * Creates an object from an array of key-value pairs with precise TypeScript\n * typing. This is a type-safe wrapper around `Object.fromEntries` that\n * provides better type inference and compile-time guarantees about the\n * resulting object structure.\n *\n * **Type Behavior**:\n *\n * - When entries is a fixed-length tuple, the exact object type is inferred\n * - When entries has dynamic length with union key types, `Partial` is applied\n * to prevent incorrect assumptions about which keys will be present\n *\n * @example\n *\n * ```ts\n * // Fixed-length tuple - exact type inferred\n * const entries1 = [\n * ['name', 'David'],\n * ['age', 25],\n * ['active', true],\n * ] as const;\n *\n * const obj1 = Obj.fromEntries(entries1);\n *\n * assert.deepStrictEqual(obj1, {\n * name: 'David',\n * age: 25,\n * active: true,\n * });\n *\n * // Dynamic length array - Partial type applied\n * const dynamicEntries: readonly (readonly ['x' | 'y', number])[] = [\n * ['x', 10],\n * ['y', 20],\n * ] as const;\n *\n * const obj2 = Obj.fromEntries(dynamicEntries);\n *\n * assert.deepStrictEqual(obj2, { x: 10, y: 20 });\n * ```\n *\n * @template Entries - The readonly array type of key-value entry tuples\n * @param entries - An array of readonly key-value entry tuples `[key, value]`\n * @returns An object created from the entries with precise typing\n */\n export const fromEntries = <\n const Entries extends readonly (readonly [PropertyKey, unknown])[],\n >(\n entries: Entries,\n ): IsFixedLengthList<Entries> extends true\n ? TsDataForgeInternals.EntriesToObject<Entries>\n : TsDataForgeInternals.PartialIfKeyIsUnion<\n TsDataForgeInternals.KeysOfEntries<Entries>,\n ReadonlyRecord<\n TsDataForgeInternals.KeysOfEntries<Entries>,\n TsDataForgeInternals.ValuesOfEntries<Entries>\n >\n > =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(entries) as never;\n\n /**\n * Transforms every value of a record, leaving the key set untouched.\n *\n * **Type Behavior**: the result is a mapped type over `keyof R`, so the keys\n * — and their optional modifiers — survive verbatim:\n * `{ a: number; b?: number }` maps to `{ a: V2; b?: V2 }`, and a record with\n * an index signature stays total rather than becoming `Partial`.\n *\n * This is what `Object.fromEntries(Object.entries(record).map(...))` cannot\n * express: an entries array carries no evidence that it still covers every\n * key of the record it came from, so its element type is all the return type\n * can be built from. Going through a mapped type instead states the\n * invariant that a value-only transform preserves the key set.\n *\n * **Key handling**: keys reach the callback the way `Object.entries` yields\n * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are\n * not enumerated by `Object.entries`; they are dropped from both the result\n * and its type.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/map-example.mts -->\n *\n * ```ts\n * const scores = { alice: 1, bob: 2 } as const;\n *\n * const doubled = Obj.map(scores, (value) => value * 2);\n *\n * assert.deepStrictEqual(doubled, { alice: 2, bob: 4 });\n *\n * // The key is available as the second argument.\n * const labelled = Obj.map(scores, (value, key) => `${key}=${value}`);\n *\n * assert.deepStrictEqual(labelled, { alice: 'alice=1', bob: 'bob=2' });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/map-example.mts -->\n *\n * @template R - The type of the source record\n * @template V2 - The type the callback returns for every key\n * @param record - The record whose values are transformed\n * @param mapFn - Called once per own enumerable string key, with the value\n * and the key\n * @returns A new record with the same keys as `record` and the mapped values\n */\n export const map = <const R extends UnknownRecord, V2>(\n record: R,\n mapFn: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => V2,\n ): TsDataForgeInternals.MappedRecord<R, V2> => {\n // `Object.entries` erases both the key and the value type of `R`, so the\n // callback is widened once here instead of asserting on every entry.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const mapFnWidened = mapFn as (value: unknown, key: string) => V2;\n\n return (\n // `Object.entries` enumerates exactly the own enumerable string keys of\n // `record`, and nothing here adds or removes an entry, so the result has\n // the key set `MappedRecord` claims.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).map(\n ([k, v]) => [k, mapFnWidened(v, k)] as const,\n ),\n ) as never\n );\n };\n\n /**\n * Keeps the entries whose value the predicate accepts, leaving the values\n * themselves untouched.\n *\n * **Type Behavior**: the surviving keys are the keys of the source record,\n * made optional — the predicate may reject any of them. A record keyed by an\n * index signature stays total instead, because it names no specific key that\n * could go missing.\n *\n * Passing a type guard narrows the value type of the result, which is what\n * `Object.fromEntries(Object.entries(record).filter(guard))` loses.\n *\n * **Key handling**: keys reach the callback the way `Object.entries` yields\n * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are\n * not enumerated by `Object.entries`; they are dropped from both the result\n * and its type.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/filter-example.mts -->\n *\n * ```ts\n * const scores = { alice: 1, bob: 2 } as const;\n *\n * const passing = Obj.filter(scores, (value) => value > 1);\n *\n * assert.deepStrictEqual(passing, { bob: 2 });\n *\n * // The key is available as the second argument.\n * const notAlice = Obj.filter(scores, (_value, key) => key !== 'alice');\n *\n * assert.deepStrictEqual(notAlice, { bob: 2 });\n *\n * // A type guard narrows the value type of the result.\n * const mixed: UnknownRecord = { a: 1, b: 'x' } as const;\n *\n * const strings = Obj.filter(mixed, isString);\n *\n * assert.deepStrictEqual(strings, { b: 'x' });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/filter-example.mts -->\n *\n * @template R - The type of the source record\n * @template V2 - The type the guard narrows values to\n * @param record - The record whose entries are filtered\n * @param predicate - Called once per own enumerable string key, with the\n * value and the key\n * @returns A new record holding only the accepted entries\n */\n export function filter<const R extends UnknownRecord, V2 extends R[keyof R]>(\n record: R,\n predicate: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => value is V2,\n ): TsDataForgeInternals.FilteredRecord<\n TsDataForgeInternals.MappedRecord<R, V2>\n >;\n\n export function filter<const R extends UnknownRecord>(\n record: R,\n predicate: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => boolean,\n ): TsDataForgeInternals.FilteredRecord<R>;\n\n export function filter<const R extends UnknownRecord>(\n record: R,\n predicate: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => boolean,\n ): TsDataForgeInternals.FilteredRecord<R> {\n // `Object.entries` erases both the key and the value type of `R`, so the\n // callback is widened once here instead of asserting on every entry.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const predicateWidened = predicate as (\n value: unknown,\n key: string,\n ) => boolean;\n\n return (\n // `Object.entries` enumerates exactly the own enumerable string keys of\n // `record`, and filtering only ever removes entries, so the result has a\n // subset of those keys — which is what `FilteredRecord` claims.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).filter(([k, v]) => predicateWidened(v, k)),\n ) as never\n );\n }\n\n /**\n * Transforms and drops entries in one pass: the callback returns\n * `Optional.some(value)` to keep an entry with a new value, or\n * `Optional.none` to drop it.\n *\n * **Type Behavior**: as with {@link filter}, the surviving keys are the keys\n * of the source record made optional, and a record keyed by an index\n * signature stays total. Unlike {@link filter}, every kept value takes the\n * type the callback returns.\n *\n * `Optional` rather than `undefined` marks the dropped entries, so a record\n * whose values are legitimately `undefined` stays expressible.\n *\n * **Key handling**: keys reach the callback the way `Object.entries` yields\n * them, so a numeric key `1` arrives as `'1'`. Symbol-keyed properties are\n * not enumerated by `Object.entries`; they are dropped from both the result\n * and its type.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/filter-map-example.mts -->\n *\n * ```ts\n * const scores = { alice: 1, bob: 2 } as const;\n *\n * // `Optional.some` keeps an entry with a new value, `Optional.none` drops it.\n * const labelled = Obj.filterMap(scores, (value, key) =>\n * value > 1 ? Optional.some(`${key}=${value}`) : Optional.none,\n * );\n *\n * assert.deepStrictEqual(labelled, { bob: 'bob=2' });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/filter-map-example.mts -->\n *\n * @template R - The type of the source record\n * @template V2 - The type the callback returns for the entries it keeps\n * @param record - The record whose entries are transformed and filtered\n * @param mapFn - Called once per own enumerable string key, with the value\n * and the key\n * @returns A new record holding only the kept entries, with mapped values\n */\n export const filterMap = <const R extends UnknownRecord, V2>(\n record: R,\n mapFn: (\n value: R[keyof R],\n key: TsDataForgeInternals.MappedRecordKey<R>,\n ) => Optional<V2>,\n ): TsDataForgeInternals.FilteredRecord<\n TsDataForgeInternals.MappedRecord<R, V2>\n > => {\n // `Object.entries` erases both the key and the value type of `R`, so the\n // callback is widened once here instead of asserting on every entry.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n const mapFnWidened = mapFn as (value: unknown, key: string) => Optional<V2>;\n\n return (\n // `Object.entries` enumerates exactly the own enumerable string keys of\n // `record`, and this only ever drops entries or replaces their values, so\n // the result has a subset of those keys with `V2` values.\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(\n Object.entries(record).flatMap(([k, v]) => {\n const mapped = mapFnWidened(v, k);\n\n return Optional.isSome(mapped) ? [[k, mapped.value] as const] : [];\n }),\n ) as never\n );\n };\n\n /**\n * Merges multiple records into a single record using `Object.assign`.\n * Later records override properties from earlier records with the same key.\n *\n * @example\n *\n * <!-- doc:embed:jsdoc:example:./samples/src/object/merge-example.mts -->\n *\n * ```ts\n * const a = { a: 0, b: 0 } as const;\n *\n * const b = { b: 1, c: 0 } as const;\n *\n * const result = Obj.merge(a, b);\n *\n * assert.deepStrictEqual(result, { a: 0, b: 1, c: 0 });\n * ```\n *\n * <!-- /doc:embed:jsdoc:example:./samples/src/object/merge-example.mts -->\n *\n * @param records - The records to merge\n * @returns A new record with all properties merged\n */\n export const merge = <const Records extends readonly UnknownRecord[]>(\n ...records: Records\n ): TsDataForgeInternals.MergeAll<Records> =>\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n Object.fromEntries(records.flatMap((r) => Object.entries(r))) as never;\n\n /**\n * Deeply picks a nested property from an object along the specified key path.\n * Supports both direct and curried usage.\n *\n * @example\n *\n * ```ts\n * const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;\n *\n * // Direct usage\n * const result = Obj.deepPick(data, ['a', 'b', 'c']);\n *\n * assert.deepStrictEqual(result, { a: { b: { c: 1 } } });\n *\n * // Curried usage with pipe\n * const pickAB = Obj.deepPick(['a', 'b']);\n *\n * const result2 = pipe(data).map(pickAB).value;\n *\n * assert.deepStrictEqual(result2, { a: { b: { c: 1, d: 2 } } });\n * ```\n *\n * @template R - The type of the input record\n * @template Path - The key path tuple\n * @param record - The source record\n * @param path - A readonly tuple of keys representing the nested path\n * @returns A new record containing only the nested property at the path\n */\n export function deepPick<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(record: R, path: Path): DeepPick<R, Path>;\n\n // Curried version\n export function deepPick<const Path extends readonly (string | number)[]>(\n path: Path,\n ): <const R extends UnknownRecord>(record: R) => DeepPick<R, Path>;\n\n export function deepPick<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(\n ...args: readonly [record: R, path: Path] | readonly [path: Path]\n ): DeepPick<R, Path> | ((record: R) => DeepPick<R, Path>) {\n switch (args.length) {\n case 2: {\n const [record, path] = args;\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n deepPickImpl(record, path) as never\n );\n }\n\n case 1: {\n const [path] = args;\n\n return (record: R) => deepPick(record, path);\n }\n }\n }\n\n /**\n * Deeply omits a nested property from an object along the specified key path.\n * Supports both direct and curried usage.\n *\n * @example\n *\n * ```ts\n * const data = { a: { b: { c: 1, d: 2 }, e: 3 }, f: 4 } as const;\n *\n * // Direct usage\n * const result = Obj.deepOmit(data, ['a', 'b', 'c']);\n *\n * assert.deepStrictEqual(result, { a: { b: { d: 2 }, e: 3 }, f: 4 });\n *\n * // Curried usage with pipe\n * const omitAB = Obj.deepOmit(['a', 'b']);\n *\n * const result2 = pipe(data).map(omitAB).value;\n *\n * assert.deepStrictEqual(result2, { a: { e: 3 }, f: 4 });\n * ```\n *\n * @template R - The type of the input record\n * @template Path - The key path tuple\n * @param record - The source record\n * @param path - A readonly tuple of keys representing the nested path to omit\n * @returns A new record with the nested property at the path removed\n */\n export function deepOmit<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(record: R, path: Path): DeepOmit<R, Path>;\n\n // Curried version\n export function deepOmit<const Path extends readonly (string | number)[]>(\n path: Path,\n ): <const R extends UnknownRecord>(record: R) => DeepOmit<R, Path>;\n\n export function deepOmit<\n const R extends UnknownRecord,\n const Path extends readonly (string | number)[],\n >(\n ...args: readonly [record: R, path: Path] | readonly [path: Path]\n ): DeepOmit<R, Path> | ((record: R) => DeepOmit<R, Path>) {\n switch (args.length) {\n case 2: {\n const [record, path] = args;\n\n return (\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n deepOmitImpl(record, path) as never\n );\n }\n\n case 1: {\n const [path] = args;\n\n return (record: R) => deepOmit(record, path);\n }\n }\n }\n}\n\nconst deepPickImpl = (\n record: UnknownRecord,\n path: readonly (string | number)[],\n): UnknownRecord => {\n if (!Arr.isNonEmpty(path)) return record;\n\n const head = path[0];\n\n if (!hasKey(record, head)) return {};\n\n const value = record[head];\n\n const tail = path.slice(1);\n\n if (!Arr.isNonEmpty(tail)) return { [head]: value };\n\n if (!isRecord(value)) return { [head]: {} };\n\n return {\n [head]: deepPickImpl(value, tail),\n };\n};\n\nconst deepOmitImpl = (\n record: UnknownRecord,\n path: readonly (string | number)[],\n): UnknownRecord => {\n if (!Arr.isNonEmpty(path)) return record;\n\n const head = path[0];\n\n if (!hasKey(record, head)) return record;\n\n const tail = path.slice(1);\n\n if (!Arr.isNonEmpty(tail)) {\n return Object.fromEntries(\n Object.entries(record).filter(([k]) => k !== head),\n );\n }\n\n const value = record[head];\n\n if (!isRecord(value)) return record;\n\n return {\n ...record,\n [head]: deepOmitImpl(value, tail),\n };\n};\n\n/**\n * @internal\n * Internal type utilities for the Obj module.\n */\ndeclare namespace TsDataForgeInternals {\n type RecursionLimit = 20;\n\n /** - `[['x', 1], ['y', 3]]` -> `{ x: 1, y: 3 }` */\n export type EntriesToObject<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n > = Readonly<EntriesToObjectImpl<{}, Entries>>;\n\n /** @internal */\n type EntriesToObjectImpl<\n R,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > =\n TypeEq<Entries['length'], 0> extends true\n ? R\n : EntriesToObjectImpl<\n R & ReadonlyRecord<Entries[0][0], Entries[0][1]>,\n List.Tail<Entries>\n >;\n\n /**\n * - `['x' | 'y' | 'z', number][]]` -> `'x' | 'y' | 'z'`\n * - `[['a' | 'b' | 'c', number], ...['x' | 'y' | 'z', number][]]` -> `'a' |\n * 'b' | 'c' | 'x' | 'y' | 'z'`\n *\n * @note To handle the second example above, recursion needs to be performed on infinite-length Entries,\n * but since the timing to stop cannot be determined, a recursion limit is set.\n */\n export type KeysOfEntries<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > = KeysOfEntriesImpl<never, Entries, RecursionLimit>;\n\n type KeysOfEntriesImpl<\n K,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n RemainingNumRecursions extends number,\n > =\n TypeEq<RemainingNumRecursions, 0> extends true\n ? K\n : TypeEq<Entries['length'], 0> extends true\n ? K\n : KeysOfEntriesImpl<\n K | Entries[0][0],\n List.Tail<Entries>,\n Decrement<RemainingNumRecursions>\n >;\n\n export type ValuesOfEntries<\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n > = ValuesOfEntriesImpl<never, Entries, RecursionLimit>;\n\n type ValuesOfEntriesImpl<\n K,\n Entries extends readonly (readonly [PropertyKey, unknown])[],\n RemainingNumRecursions extends number,\n > =\n TypeEq<RemainingNumRecursions, 0> extends true\n ? K\n : TypeEq<Entries['length'], 0> extends true\n ? K\n : ValuesOfEntriesImpl<\n K | Entries[0][1],\n List.Tail<Entries>,\n Decrement<RemainingNumRecursions>\n >;\n\n export type PartialIfKeyIsUnion<K, T> =\n IsUnion<K> extends true ? Partial<T> : T;\n\n /**\n * The keys `Object.entries` yields for `R`: symbol keys are not enumerated,\n * and a numeric key `1` arrives as the string `'1'`.\n */\n export type MappedRecordKey<R> = ToString<RelaxedExclude<keyof R, symbol>>;\n\n /**\n * `R` with every value replaced by `V2`. Homomorphic over `keyof R`, so\n * optional modifiers and index signatures are preserved; the key remapping\n * drops the symbol keys that `Object.entries` would not have visited.\n */\n export type MappedRecord<R, V2> = Readonly<{\n [K in keyof R as K extends symbol ? never : K]: V2;\n }>;\n\n /** `R` without the symbol keys `Object.entries` never visits. */\n type StringKeyedRecord<R> = Readonly<{\n [K in keyof R as K extends symbol ? never : K]: R[K];\n }>;\n\n /**\n * The result of dropping entries from `R`: symbol keys go away, and the\n * remaining keys become optional because a predicate may reject any of them.\n *\n * A record keyed by an index signature stays total instead. It names no\n * specific key that could go missing, and `noUncheckedIndexedAccess` already\n * adds `| undefined` on access, so making it `Partial` would add nothing and\n * would only stop the result from being assignable back to the record type it\n * came from.\n */\n export type FilteredRecord<R> = string extends keyof R\n ? StringKeyedRecord<R>\n : number extends keyof R\n ? StringKeyedRecord<R>\n : Readonly<{ [K in keyof R as K extends symbol ? never : K]?: R[K] }>;\n\n /**\n * Merges two object types where keys in B override keys in A, preserving optional modifiers.\n *\n * This implementation uses a sophisticated technique to preserve optional property modifiers (`?`)\n * during the merge operation, which would otherwise be lost in a naive mapped type implementation.\n *\n * ## Core Technique: Optional Property Detection\n *\n * Uses `{} extends Pick<T, K>` to determine if a property is optional:\n * - **Required property**: `Pick<T, 'x'>` = `{ x: number }` → `{}` does NOT extend it (false)\n * - **Optional property**: `Pick<T, 'y'>` = `{ y?: string }` → `{}` DOES extend it (true)\n *\n * This works because `{}` (empty object) is assignable to objects with only optional properties\n * but not to objects with required properties.\n *\n * ## Implementation Strategy\n *\n * The type is constructed as an intersection of five mapped types:\n *\n * 1. **Required properties from B** - Properties in B that are required (override A completely)\n * 2. **Optional properties from B (not in A)** - New optional properties from B\n * 3. **Optional properties from B (in A)** - Union of A[K] | B[K] to preserve both possibilities\n * 4. **Required properties only in A** - Properties in A but not in B that are required\n * 5. **Optional properties only in A** - Properties in A but not in B that are optional (with `?` modifier)\n *\n * Finally, the intersection is flattened using an optional-preserving identity mapping that\n * re-applies the optional detection logic to maintain the `?` modifiers in the final type.\n *\n * @example\n * ```ts\n * type A = Readonly<{ x: number; y?: string }>;\n *\n * type B = Readonly<{ y?: number; z?: boolean }>;\n *\n * type Result = MergeTwo<A, B>;\n * // Result: Readonly<{ x: number; y?: string | number; z?: boolean }>\n * ```\n */\n // transformer-ignore-next-line\n type MergeTwo<A extends UnknownRecord, B extends UnknownRecord> = {\n // 1. Required properties from B (override A completely)\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n readonly [K in keyof B as {} extends StrictPick<B, K> ? never : K]: B[K];\n } & {\n // 2. Optional properties from B that are NOT in A\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in keyof B as {} extends StrictPick<B, K>\n ? K extends keyof A\n ? never\n : K\n : never\n ]?: B[K];\n } & {\n // 3. Optional properties from B that ARE in A (create union)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in keyof B as {} extends StrictPick<B, K>\n ? K extends keyof A\n ? K\n : never\n : never\n ]?: K extends keyof A ? A[K] | B[K] : never;\n } & {\n // 4. Required properties only in A (not overridden by B)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in RelaxedExclude<keyof A, keyof B> as {} extends StrictPick<A, K>\n ? never\n : K\n ]: A[K];\n } & {\n // 5. Optional properties only in A (not overridden by B)\n readonly [\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n K in RelaxedExclude<keyof A, keyof B> as {} extends StrictPick<A, K>\n ? K\n : never\n ]?: A[K];\n } extends infer O\n ? Readonly<\n {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n [K in keyof O as {} extends StrictPick<O, K> ? never : K]: O[K];\n } & {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n [K in keyof O as {} extends StrictPick<O, K> ? K : never]?: O[K];\n }\n >\n : never;\n\n /** Sequentially merges a tuple of object types from left to right. */\n export type MergeAll<\n Records extends readonly UnknownRecord[],\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n Acc extends UnknownRecord = {},\n > =\n IsFixedLengthList<Records> extends false\n ? ArrayElement<Records>\n : Records extends readonly [\n infer First extends UnknownRecord,\n ...infer Rest extends readonly UnknownRecord[],\n ]\n ? MergeAll<Rest, MergeTwo<Acc, First>>\n : Acc;\n}\n"],"names":["Obj","Optional.isSome","Arr.isNonEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BO,IAAU;AAAA,CAAV,CAAUA,IAAAA,KAAV;AA2CE,EAAMA,KAAA,SAAA,GAAY,CACvB,GACA,CAAA,EACA,EAAA,GAA0C,OAAO,EAAA,KACrC;AACZ,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA;AAEjC,IAAA,MAAM,QAAA,GAAW,MAAA,CAAO,OAAA,CAAQ,CAAC,CAAA;AAEjC,IAAA,IAAI,QAAA,CAAS,MAAA,KAAW,QAAA,CAAS,MAAA,EAAQ,OAAO,KAAA;AAEhD,IAAA,OAAO,QAAA,CAAS,KAAA,CAAM,CAAC,CAAC,CAAA,EAAG,CAAC,CAAA,KAAM,EAAA,CAAG,CAAA,CAAE,CAAC,CAAA,EAAG,CAAC,CAAC,CAAA;AAAA,EAC/C,CAAA;AAyDO,EAAA,SAAS,QAIX,IAAA,EAGmD;AACtD,IAAA,QAAQ,KAAK,MAAA;AAAQ,MACnB,KAAK,CAAA,EAAG;AACN,QAAA,MAAM,CAAC,MAAA,EAAQ,IAAI,CAAA,GAAI,IAAA;AAEvB,QAAA,MAAM,OAAA,GAAU,IAAI,GAAA,CAAa,IAAI,CAAA;AAErC,QAAA;AAAA;AAAA,UAEE,MAAA,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AC,QAAA,CAAS,KAAK,CAAA,EAAG,OAAO,MAAA;AAE7B,EAAA,OAAO;AAAA,IACL,GAAG,MAAA;AAAA,IACH,CAAC,IAAI,GAAG,YAAA,CAAa,OAAO,IAAI;AAAA,GAClC;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"debounce-function.d.mts","sourceRoot":"","sources":["../../src/others/debounce-function.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,SAAS,SAAS,OAAO,EAAE,QAChD,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,oBACX,MAAM,KACvB,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAU1B,CAAC"}
1
+ {"version":3,"file":"debounce-function.d.mts","sourceRoot":"","sources":["../../src/others/debounce-function.mts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,eAAO,MAAM,QAAQ,GAAI,IAAI,SAAS,SAAS,OAAO,EAAE,QAChD,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,oBACX,MAAM,KACvB,CAAC,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,IAAI,CAc1B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"debounce-function.mjs","sources":["../../src/others/debounce-function.mts"],"sourcesContent":["/**\n * Creates a debounced function that delays invoking `func` until after `waitMilliseconds`\n * have elapsed since the last time the debounced function was invoked.\n *\n * @template F The type of the function to debounce.\n * @param func The function to debounce.\n * @param waitMilliseconds The number of milliseconds to delay.\n * @returns The new debounced function.\n */\nexport const debounce = <Args extends readonly unknown[]>(\n func: (...args: Args) => void,\n waitMilliseconds: number,\n): ((...args: Args) => void) => {\n let mut_timeoutId: ReturnType<typeof setTimeout> | undefined;\n\n return (...args: Args): void => {\n clearTimeout(mut_timeoutId);\n\n mut_timeoutId = setTimeout(() => {\n func(...args);\n }, waitMilliseconds);\n };\n};\n"],"names":[],"mappings":"AASO,MAAM,QAAA,GAAW,CACtB,IAAA,EACA,gBAAA,KAC8B;AAC9B,EAAA,IAAI,aAAA;AAEJ,EAAA,OAAO,IAAI,IAAA,KAAqB;AAC9B,IAAA,YAAA,CAAa,aAAa,CAAA;AAE1B,IAAA,aAAA,GAAgB,WAAW,MAAM;AAC/B,MAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,IACd,GAAG,gBAAgB,CAAA;AAAA,EACrB,CAAA;AACF;;;;"}
1
+ {"version":3,"file":"debounce-function.mjs","sources":["../../src/others/debounce-function.mts"],"sourcesContent":["/**\n * Creates a debounced function that delays invoking `func` until after `waitMilliseconds`\n * have elapsed since the last time the debounced function was invoked.\n *\n * @template F The type of the function to debounce.\n * @param func The function to debounce.\n * @param waitMilliseconds The number of milliseconds to delay.\n * @returns The new debounced function.\n */\nexport const debounce = <Args extends readonly unknown[]>(\n func: (...args: Args) => void,\n waitMilliseconds: number,\n): ((...args: Args) => void) => {\n // Not `ReturnType<typeof setTimeout>`: with both the DOM and Node\n // declarations in scope that resolves to `unknown`, which `clearTimeout`\n // will not take. Naming what `clearTimeout` accepts says the same thing and\n // stays true in either environment.\n let mut_timeoutId: Parameters<typeof clearTimeout>[0];\n\n return (...args: Args): void => {\n clearTimeout(mut_timeoutId);\n\n mut_timeoutId = setTimeout(() => {\n func(...args);\n }, waitMilliseconds);\n };\n};\n"],"names":[],"mappings":"AASO,MAAM,QAAA,GAAW,CACtB,IAAA,EACA,gBAAA,KAC8B;AAK9B,EAAA,IAAI,aAAA;AAEJ,EAAA,OAAO,IAAI,IAAA,KAAqB;AAC9B,IAAA,YAAA,CAAa,aAAa,CAAA;AAE1B,IAAA,aAAA,GAAgB,WAAW,MAAM;AAC/B,MAAA,IAAA,CAAK,GAAG,IAAI,CAAA;AAAA,IACd,GAAG,gBAAgB,CAAA;AAAA,EACrB,CAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"fast-deep-equal.d.mts","sourceRoot":"","sources":["../../src/others/fast-deep-equal.mts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,KAAM,CAAC,KAAK,CAAC,KAAG,OAyF9C,CAAC"}
1
+ {"version":3,"file":"fast-deep-equal.d.mts","sourceRoot":"","sources":["../../src/others/fast-deep-equal.mts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,KAAM,CAAC,KAAK,CAAC,KAAG,OAgG9C,CAAC"}
@@ -49,7 +49,7 @@ const fastDeepEqual = (a, b) => {
49
49
  !(key === "_owner" && a["$$typeof"]) && fastDeepEqual(a[key], b[key])
50
50
  );
51
51
  }
52
- return Number.isNaN(a) && Number.isNaN(b);
52
+ return typeof a === "number" && typeof b === "number" && Number.isNaN(a) && Number.isNaN(b);
53
53
  };
54
54
 
55
55
  export { fastDeepEqual };
@@ -1 +1 @@
1
- {"version":3,"file":"fast-deep-equal.mjs","sources":["../../src/others/fast-deep-equal.mts"],"sourcesContent":["import { isMap, isRegExp, isSet, isTypedArray } from '@sindresorhus/is';\nimport { hasKey, isRecord } from '../guard/index.mjs';\n\n/**\n * The fastest deep equal with ES6 Map, Set and Typed arrays support.\n * Checks equality of Date and RegExp objects by value.\n *\n * Forked from https://github.com/epoberezkin/fast-deep-equal/blob/v3.1.3/src/index.jst\n */\nexport const fastDeepEqual = <T,>(a: T, b: T): boolean => {\n if (a === b) {\n return true;\n }\n\n if (typeof a !== typeof b) {\n return false;\n }\n\n // Arrays are handled before `isRecord`, which excludes them.\n if (Array.isArray(a)) {\n return (\n Array.isArray(b) &&\n a.constructor === b.constructor &&\n a.length === b.length &&\n a.every((ai, index) => fastDeepEqual(ai, b[index]))\n );\n }\n\n if (isRecord(a)) {\n if (!isRecord(b)) {\n return false;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (isMap(a)) {\n return (\n isMap(b) &&\n a.size === b.size &&\n a\n .entries()\n .every(\n ([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key)),\n )\n );\n }\n\n if (isSet(a)) {\n return (\n isSet(b) &&\n a.size === b.size &&\n a.entries().every(([value]) => b.has(value))\n );\n }\n\n if (isTypedArray(a)) {\n return (\n isTypedArray(b) &&\n a.length === b.length &&\n a.every((value, index) => value === b[index])\n );\n }\n\n if (isRegExp(a)) {\n return isRegExp(b) && a.source === b.source && a.flags === b.flags;\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf();\n }\n\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString();\n }\n\n const aKeys: readonly string[] = Object.keys(a);\n\n const bKeys: readonly string[] = Object.keys(b);\n\n return (\n aKeys.length === bKeys.length &&\n aKeys.every(\n (key) =>\n hasKey(b, key) &&\n // React-specific: avoid traversing React elements' _owner.\n // _owner contains circular references\n // and is not needed when comparing the actual elements (and not their owners)\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n !(key === '_owner' && a['$$typeof']) &&\n fastDeepEqual(a[key], b[key]),\n )\n );\n }\n\n // true if both NaN, false otherwise\n return Number.isNaN(a) && Number.isNaN(b);\n};\n"],"names":[],"mappings":";;;;AASO,MAAM,aAAA,GAAgB,CAAK,CAAA,EAAM,CAAA,KAAkB;AACxD,EAAA,IAAI,MAAM,CAAA,EAAG;AACX,IAAA,OAAO,IAAA;AAAA,EACT;AAEA,EAAA,IAAI,OAAO,CAAA,KAAM,OAAO,CAAA,EAAG;AACzB,IAAA,OAAO,KAAA;AAAA,EACT;AAGA,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,CAAC,CAAA,EAAG;AACpB,IAAA,OACE,KAAA,CAAM,QAAQ,CAAC,CAAA,IACf,EAAE,WAAA,KAAgB,CAAA,CAAE,WAAA,IACpB,CAAA,CAAE,MAAA,KAAW,CAAA,CAAE,UACf,CAAA,CAAE,KAAA,CAAM,CAAC,EAAA,EAAI,KAAA,KAAU,cAAc,EAAA,EAAI,CAAA,CAAE,KAAK,CAAC,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,CAAA,CAAE,KAAA,KAAU,CAAA,CAAE,KAAA;AAAA,IAC/D;AAEA,IAAA,IAAI,CAAA,CAAE,OAAA,KAAY,MAAA,CAAO,SAAA,CAAU,OAAA,EAAS;AAC1C,MAAA,OAAO,CAAA,CAAE,OAAA,EAAQ,KAAM,CAAA,CAAE,OAAA,EAAQ;AAAA,IACnC;AAEA,IAAA,IAAI,CAAA,CAAE,QAAA,KAAa,MAAA,CAAO,SAAA,CAAU,QAAA,EAAU;AAC5C,MAAA,OAAO,CAAA,CAAE,QAAA,EAAS,KAAM,CAAA,CAAE,QAAA,EAAS;AAAA,IACrC;AAEA,IAAA,MAAM,KAAA,GAA2B,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA;AAE9C,IAAA,MAAM,KAAA,GAA2B,MAAA,CAAO,IAAA,CAAK,CAAC,CAAA;AAE9C,IAAA,OACE,KAAA,CAAM,MAAA,KAAW,KAAA,CAAM,MAAA,IACvB,KAAA,CAAM,KAAA;AAAA,MACJ,CAAC,GAAA,KACC,MAAA,CAAO,CAAA,EAAG,GAAG,CAAA;AAAA;AAAA;AAAA;AAAA,MAKb,EAAE,GAAA,KAAQ,QAAA,IAAY,CAAA,CAAE,UAAU,CAAA,CAAA,IAClC,aAAA,CAAc,CAAA,CAAE,GAAG,CAAA,EAAG,CAAA,CAAE,GAAG,CAAC;AAAA,KAChC;AAAA,EAEJ;AAGA,EAAA,OAAO,OAAO,KAAA,CAAM,CAAC,CAAA,IAAK,MAAA,CAAO,MAAM,CAAC,CAAA;AAC1C;;;;"}
1
+ {"version":3,"file":"fast-deep-equal.mjs","sources":["../../src/others/fast-deep-equal.mts"],"sourcesContent":["import { isMap, isRegExp, isSet, isTypedArray } from '@sindresorhus/is';\nimport { hasKey, isRecord } from '../guard/index.mjs';\n\n/**\n * The fastest deep equal with ES6 Map, Set and Typed arrays support.\n * Checks equality of Date and RegExp objects by value.\n *\n * Forked from https://github.com/epoberezkin/fast-deep-equal/blob/v3.1.3/src/index.jst\n */\nexport const fastDeepEqual = <T,>(a: T, b: T): boolean => {\n if (a === b) {\n return true;\n }\n\n if (typeof a !== typeof b) {\n return false;\n }\n\n // Arrays are handled before `isRecord`, which excludes them.\n if (Array.isArray(a)) {\n return (\n Array.isArray(b) &&\n a.constructor === b.constructor &&\n a.length === b.length &&\n a.every((ai, index) => fastDeepEqual(ai, b[index]))\n );\n }\n\n if (isRecord(a)) {\n if (!isRecord(b)) {\n return false;\n }\n\n if (a.constructor !== b.constructor) {\n return false;\n }\n\n if (isMap(a)) {\n return (\n isMap(b) &&\n a.size === b.size &&\n a\n .entries()\n .every(\n ([key, value]) => b.has(key) && fastDeepEqual(value, b.get(key)),\n )\n );\n }\n\n if (isSet(a)) {\n return (\n isSet(b) &&\n a.size === b.size &&\n a.entries().every(([value]) => b.has(value))\n );\n }\n\n if (isTypedArray(a)) {\n return (\n isTypedArray(b) &&\n a.length === b.length &&\n a.every((value, index) => value === b[index])\n );\n }\n\n if (isRegExp(a)) {\n return isRegExp(b) && a.source === b.source && a.flags === b.flags;\n }\n\n if (a.valueOf !== Object.prototype.valueOf) {\n return a.valueOf() === b.valueOf();\n }\n\n if (a.toString !== Object.prototype.toString) {\n return a.toString() === b.toString();\n }\n\n const aKeys: readonly string[] = Object.keys(a);\n\n const bKeys: readonly string[] = Object.keys(b);\n\n return (\n aKeys.length === bKeys.length &&\n aKeys.every(\n (key) =>\n hasKey(b, key) &&\n // React-specific: avoid traversing React elements' _owner.\n // _owner contains circular references\n // and is not needed when comparing the actual elements (and not their owners)\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n !(key === '_owner' && a['$$typeof']) &&\n fastDeepEqual(a[key], b[key]),\n )\n );\n }\n\n // true if both NaN, false otherwise. `Number.isNaN` takes a number: called\n // with anything else it is always false, so the check belongs behind a\n // `typeof` guard rather than relying on that.\n return (\n typeof a === 'number' &&\n typeof b === 'number' &&\n Number.isNaN(a) &&\n Number.isNaN(b)\n );\n};\n"],"names":[],"mappings":";;;;A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A,IAAY,CAAA,CAAE,UAAU,CAAA,CAAA,IAClC,aAAA,CAAc,CAAA,CAAE,GAAG,CAAA,EAAG,CAAA,CAAE,GAAG,CAAC;AAAA,KAChC;AAAA,EAEJ;AAKA,EAAA,OACE,OAAO,CAAA,KAAM,QAAA,IACb,OAAO,CAAA,KAAM,QAAA,IACb,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA,IACd,MAAA,CAAO,KAAA,CAAM,CAAC,CAAA;AAElB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-data-forge",
3
- "version": "14.3.0",
3
+ "version": "14.5.0",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "typescript",
@@ -37,29 +37,29 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@sindresorhus/is": "^8.1.0",
40
- "ts-type-forge": "~9.2.1"
40
+ "ts-type-forge": "~9.2.2"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@emotion/react": "11.14.0",
44
44
  "@emotion/styled": "11.14.1",
45
45
  "@mui/material": "9.3.1",
46
46
  "@types/react": "19.2.18",
47
- "@vitest/browser-playwright": "4.1.10",
47
+ "@vitest/browser-playwright": "4.1.11",
48
48
  "dedent": "1.7.2",
49
- "immer": "11.1.16",
49
+ "eslint-config-typed": "5.10.0",
50
+ "eslint-plugin-ts-fortress": "1.0.5",
51
+ "eslint-plugin-ts-type-forge": "0.7.1",
52
+ "immer": "11.1.18",
50
53
  "playwright": "1.62.1",
51
54
  "prettier": "3.9.6",
52
55
  "prettier-plugin-organize-imports": "4.3.0",
53
56
  "prettier-plugin-packagejson": "3.0.2",
54
57
  "react": "19.2.8",
55
58
  "rollup": "4.62.4",
59
+ "ts-repo-utils": "10.3.2",
56
60
  "typedoc": "0.28.20",
57
61
  "typedoc-github-theme": "0.4.0",
58
- "vite": "8.2.1",
59
- "eslint-config-typed": "5.9.2",
60
- "eslint-plugin-ts-fortress": "1.0.3",
61
- "eslint-plugin-ts-type-forge": "0.6.5",
62
- "ts-repo-utils": "10.2.0"
62
+ "vite": "8.2.1"
63
63
  },
64
64
  "peerDependencies": {
65
65
  "typescript": ">=4.8"
@@ -257,7 +257,7 @@ describe('Arr modifications', () => {
257
257
  xs: T,
258
258
  ): Readonly<{ [K in keyof T]: 0 }> => toFilled(xs, 0);
259
259
 
260
- const result = blank([1, 2, 3] as const);
260
+ const result = blank([1, 2, 3]);
261
261
 
262
262
  expectType<typeof result, FixedLengthTuple<3, 0>>('=');
263
263
 
@@ -269,7 +269,7 @@ describe('Arr modifications', () => {
269
269
  xs: T,
270
270
  ): Readonly<{ [K in keyof T]: 0 }> => toFilled(0)(xs);
271
271
 
272
- const result = blank([1, 2] as const);
272
+ const result = blank([1, 2]);
273
273
 
274
274
  expectType<typeof result, FixedLengthTuple<2, 0>>('=');
275
275
 
@@ -319,7 +319,7 @@ describe('Arr modifications', () => {
319
319
  xs: T,
320
320
  ): Readonly<{ [K in keyof T]: number }> => toRangeFilled(xs, 0, [1, 2]);
321
321
 
322
- const result = blankMiddle([1, 2, 3] as const);
322
+ const result = blankMiddle([1, 2, 3]);
323
323
 
324
324
  expectType<typeof result, FixedLengthTuple<3, number>>('=');
325
325
 
@@ -79,10 +79,17 @@ const findImpl = <E,>(
79
79
  predicate as () => boolean,
80
80
  );
81
81
 
82
- expectType<
83
- Parameters<typeof array.findIndex>[0],
84
- (value: E, index: number, arr: readonly E[]) => unknown
85
- >('=');
82
+ // Left as a comment rather than asserted. This pinned the shape of the
83
+ // standard library's `findIndex`, and the shape differs between the stock
84
+ // library and the strict one — `(value, index, obj: this) => boolean` there
85
+ // against `(value, index, arr: readonly E[]) => unknown` here. `src` ships
86
+ // to consumers so that "Go to Definition" reaches it, so an assertion that
87
+ // only holds under one of them shows up as an error in their editor.
88
+ //
89
+ // expectType<
90
+ // Parameters<typeof array.findIndex>[0],
91
+ // (value: E, index: number, arr: readonly E[]) => unknown
92
+ // >('=');
86
93
 
87
94
  expectType<
88
95
  typeof predicate,
@@ -162,10 +169,17 @@ const findLastImpl = <E,>(
162
169
  predicate as () => boolean,
163
170
  );
164
171
 
165
- expectType<
166
- Parameters<typeof array.findIndex>[0],
167
- (value: E, index: number, arr: readonly E[]) => unknown
168
- >('=');
172
+ // Left as a comment rather than asserted. This pinned the shape of the
173
+ // standard library's `findIndex`, and the shape differs between the stock
174
+ // library and the strict one — `(value, index, obj: this) => boolean` there
175
+ // against `(value, index, arr: readonly E[]) => unknown` here. `src` ships
176
+ // to consumers so that "Go to Definition" reaches it, so an assertion that
177
+ // only holds under one of them shows up as an error in their editor.
178
+ //
179
+ // expectType<
180
+ // Parameters<typeof array.findIndex>[0],
181
+ // (value: E, index: number, arr: readonly E[]) => unknown
182
+ // >('=');
169
183
 
170
184
  expectType<
171
185
  typeof predicate,
@@ -267,7 +267,7 @@ describe('Arr shape invariants', () => {
267
267
  );
268
268
 
269
269
  assert.deepStrictEqual<readonly string[]>(
270
- toSortedNonNumberInGenericContext(['c', 'a', 'b'] as const),
270
+ toSortedNonNumberInGenericContext(['c', 'a', 'b']),
271
271
  ['a', 'b', 'c'],
272
272
  );
273
273
 
@@ -313,12 +313,12 @@ describe('Arr shape invariants', () => {
313
313
  );
314
314
 
315
315
  assert.deepStrictEqual<readonly number[]>(
316
- uniqInGenericContext([1, 1, 2] as const),
316
+ uniqInGenericContext([1, 1, 2]),
317
317
  [1, 2],
318
318
  );
319
319
 
320
320
  assert.deepStrictEqual<readonly number[]>(
321
- uniqByInGenericContext([1, 1, 2] as const),
321
+ uniqByInGenericContext([1, 1, 2]),
322
322
  [1, 2],
323
323
  );
324
324
  });
@@ -77,7 +77,7 @@ describe('Arr transformations', () => {
77
77
  boxes: T,
78
78
  ): Readonly<{ [K in keyof T]: unknown }> => map(boxes, (b) => b.v);
79
79
 
80
- const result = mapValues([{ v: 1 }, { v: 'a' }] as const);
80
+ const result = mapValues([{ v: 1 }, { v: 'a' }]);
81
81
 
82
82
  expectType<typeof result, FixedLengthTuple<2, unknown>>('=');
83
83