@guillaume-docquier/tools-ts 4.1.0 → 4.2.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.
package/README.md CHANGED
@@ -101,12 +101,13 @@ consistent context, scopes, formatting, and redaction.
101
101
  Use these small utilities to keep common asynchronous and callback patterns
102
102
  consistent.
103
103
 
104
- | Export | What it is | Use it when |
105
- | ----------------- | ----------------------------- | ------------------------------------------------------------------------------- |
106
- | `setTimeoutAsync` | Promise-based timeout helper. | You want `await`-friendly delays that work in browser and Node environments. |
107
- | `debounce` | Creates a debounced callback. | A repeated event should trigger work only after calls have settled for a delay. |
108
- | `noop` | Synchronous no-op function. | You need a safe default callback that intentionally does nothing. |
109
- | `asyncNoop` | Asynchronous no-op function. | You need a safe default async callback or hook that resolves immediately. |
104
+ | Export | What it is | Use it when |
105
+ | ----------------- | ------------------------------------------ | ------------------------------------------------------------------------------- |
106
+ | `setTimeoutAsync` | Promise-based timeout helper. | You want `await`-friendly delays that work in browser and Node environments. |
107
+ | `debounce` | Creates a debounced callback. | A repeated event should trigger work only after calls have settled for a delay. |
108
+ | `noop` | Synchronous no-op function. | You need a safe default callback that intentionally does nothing. |
109
+ | `asyncNoop` | Asynchronous no-op function. | You need a safe default async callback or hook that resolves immediately. |
110
+ | `omit` | Runtime equivalent of `Omit<TType, TKey>`. | You need to remove keys from an object. |
110
111
 
111
112
  ### Measurement
112
113
 
@@ -6,6 +6,7 @@ export { isNodeJSError } from "./errors/isNodeJSError.js";
6
6
  export { getEnumKey } from "./getEnumKey.js";
7
7
  export type * from "./utility-types.js";
8
8
  export { asArray } from "./asArray.js";
9
+ export { omit } from "./omit.js";
9
10
  export { Assert } from "./Assert.js";
10
11
  export { Result, type Success, type Failure } from "./Result.js";
11
12
  export { Measure } from "./Measure.js";
@@ -5,6 +5,7 @@ export { NotImplementedError } from "./errors/NotImplementedError.js";
5
5
  export { isNodeJSError } from "./errors/isNodeJSError.js";
6
6
  export { getEnumKey } from "./getEnumKey.js";
7
7
  export { asArray } from "./asArray.js";
8
+ export { omit } from "./omit.js";
8
9
  export { Assert } from "./Assert.js";
9
10
  export { Result } from "./Result.js";
10
11
  export { Measure } from "./Measure.js";
@@ -1 +1 @@
1
- {"version":3,"file":"entry.tools-ts.js","sourceRoot":"","sources":["../src/entry.tools-ts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,MAAM,EAA8B,MAAM,aAAa,CAAA;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAClC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAA;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAA;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAKvE,OAAO,EAAE,Q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;AAEtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAA;AAKvE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,SAAS,EAA4B,MAAM,cAAc,CAAA;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA"}
package/dist/noop.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Does nothing.
3
- * Usually used a default parameter for optional callbacks.
3
+ * Usually used as a default parameter for optional callbacks.
4
4
  */
5
5
  export declare function noop(): void;
6
6
  /**
7
7
  * Asynchronously does nothing.
8
- * Usually used a default parameter for async optional callbacks.
8
+ * Usually used as a default parameter for async optional callbacks.
9
9
  */
10
10
  export declare function asyncNoop(): Promise<void>;
package/dist/noop.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Does nothing.
3
- * Usually used a default parameter for optional callbacks.
3
+ * Usually used as a default parameter for optional callbacks.
4
4
  */
5
5
  export function noop() { }
6
6
  /**
7
7
  * Asynchronously does nothing.
8
- * Usually used a default parameter for async optional callbacks.
8
+ * Usually used as a default parameter for async optional callbacks.
9
9
  */
10
10
  export async function asyncNoop() { }
11
11
  //# sourceMappingURL=noop.js.map
package/dist/omit.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Returns the given record with omitted keys.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const record = { a: 1, b: 2, c: 3 }
7
+ * const omitted = omit(record, "b", "c")
8
+ *
9
+ * console.log(record) // { a: 1, b: 2, c: 3 }
10
+ * console.log(omitted) // { a: 1 }
11
+ * ```
12
+ */
13
+ export declare function omit<TRecord extends Record<string, unknown>, TKey extends keyof TRecord>(record: Readonly<TRecord>, ...keys: TKey[]): Omit<TRecord, TKey>;
package/dist/omit.js ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Returns the given record with omitted keys.
3
+ *
4
+ * @example
5
+ * ```ts
6
+ * const record = { a: 1, b: 2, c: 3 }
7
+ * const omitted = omit(record, "b", "c")
8
+ *
9
+ * console.log(record) // { a: 1, b: 2, c: 3 }
10
+ * console.log(omitted) // { a: 1 }
11
+ * ```
12
+ */
13
+ export function omit(record, ...keys) {
14
+ const result = { ...record };
15
+ for (const key of keys) {
16
+ delete result[key];
17
+ }
18
+ return result;
19
+ }
20
+ //# sourceMappingURL=omit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"omit.js","sourceRoot":"","sources":["../src/omit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,IAAI,CAClB,MAAyB,EACzB,GAAG,IAAY;IAEf,MAAM,MAAM,GAAG,EAAE,GAAG,MAAM,EAAE,CAAA;IAE5B,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,OAAO,MAAM,CAAC,GAAG,CAAC,CAAA;IACpB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guillaume-docquier/tools-ts",
3
- "version": "4.1.0",
3
+ "version": "4.2.0",
4
4
  "description": "My personal collection of typescript tools",
5
5
  "homepage": "https://github.com/Guillaume-Docquier/tools-ts",
6
6
  "repository": {