@douglasneuroinformatics/libjs 0.2.0 → 0.3.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/dist/index.d.ts CHANGED
@@ -4,4 +4,5 @@ export * from './object.js';
4
4
  export * from './random.js';
5
5
  export * from './range.js';
6
6
  export * from './string.js';
7
+ export * from './types.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -4,3 +4,4 @@ export * from './object.js';
4
4
  export * from './random.js';
5
5
  export * from './range.js';
6
6
  export * from './string.js';
7
+ export * from './types.js';
@@ -0,0 +1,19 @@
1
+ import type { IfNever } from 'type-fest';
2
+ /**
3
+ * Return whether `T` or any record nested therein contains the key `K`
4
+ *
5
+ * @example
6
+ * HasNestedKey<{ a: string; b: { c: { d: number }[] } }, 'a'>; // true
7
+ * HasNestedKey<{ a: string; b: { c: { d: number }[] } }, 'b'>; // true
8
+ * HasNestedKey<{ a: string; b: { c: { d: number }[] } }, 'c'>; // true
9
+ * HasNestedKey<{ a: string; b: { c: { d: number }[] } }, 'd'>; // true
10
+ * HasNestedKey<{ a: string; b: { c: { d: number }[] } }, 'e'>; // false
11
+ * HasNestedKey<{ a: string; b: { c: { d: number }[] } }, 'd' | 'e'>; // true
12
+ * HasNestedKey<{ a: string; b: { c: { d: number }[] } }, string>; // true
13
+ */
14
+ export type HasNestedKey<T, P extends string> = T extends {
15
+ [key: string]: unknown;
16
+ } ? IfNever<keyof {
17
+ [K in keyof T as K extends P ? K : HasNestedKey<T[K], P> extends true ? K : never]: never;
18
+ }, false, true> : T extends (infer U)[] ? HasNestedKey<U, P> : false;
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,GAChF,OAAO,CACL,MAAM;KACH,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,CAAC,GAAG,KAAK,GAAG,KAAK;CAC1F,EACD,KAAK,EACL,IAAI,CACL,GACD,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GACnB,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,GAClB,KAAK,CAAC"}
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@douglasneuroinformatics/libjs",
3
3
  "type": "module",
4
- "version": "0.2.0",
4
+ "version": "0.3.0",
5
5
  "packageManager": "pnpm@8.15.3",
6
6
  "description": "A collection of utility functions and types for Node.js and the browser",
7
7
  "author": {