@battis/typescript-tricks 0.2.0 → 0.2.2

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.
@@ -1,3 +1,9 @@
1
1
  export type Constructor<T> = new (...args: any[]) => T;
2
2
  export declare const isConstructor: (value: any) => value is Constructor<any>;
3
+ /**
4
+ * TODO is this even useful?
5
+ * Not sure why I included it, it seems more likely that it's related to
6
+ * wanting [this](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards)?
7
+ * @ see https://stackoverflow.com/a/65152869/294171
8
+ */
3
9
  export declare function instanceOf<TElements, TFilter extends TElements>(array: TElements[], filterType: Constructor<TFilter>): TFilter[];
@@ -5,7 +5,12 @@ const isConstructor = (value) => {
5
5
  return !!value && !!value.prototype && !!value.prototype.constructor;
6
6
  };
7
7
  exports.isConstructor = isConstructor;
8
- // https://stackoverflow.com/a/65152869/294171
8
+ /**
9
+ * TODO is this even useful?
10
+ * Not sure why I included it, it seems more likely that it's related to
11
+ * wanting [this](https://www.typescriptlang.org/docs/handbook/advanced-types.html#user-defined-type-guards)?
12
+ * @ see https://stackoverflow.com/a/65152869/294171
13
+ */
9
14
  function instanceOf(array, filterType) {
10
15
  return array.filter((e) => e instanceof filterType);
11
16
  }
@@ -4,3 +4,7 @@ export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclu
4
4
  export type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & {
5
5
  [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, undefined>>;
6
6
  }[Keys];
7
+ /** @see https://stackoverflow.com/a/51365037 */
8
+ export type RecursivePartial<T> = {
9
+ [P in keyof T]?: T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object | undefined ? RecursivePartial<T[P]> : T[P];
10
+ };
@@ -2,3 +2,6 @@ export type AsynchronousFunction = () => Promise<any>;
2
2
  export type Nullable<T> = T | null;
3
3
  export type Optional<T> = T | undefined;
4
4
  export type Subset<T, U extends T> = T;
5
+ export type AssociativeArray<T> = {
6
+ [key: string]: T;
7
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@battis/typescript-tricks",
3
3
  "description": "A handful of useful types and operators",
4
- "version": "0.2.0",
4
+ "version": "0.2.2",
5
5
  "author": "Seth Battis <seth@battis.net>",
6
6
  "license": "GPL-3.0",
7
7
  "main": "./dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "build:compile": "tsc",
24
24
  "release": "run-s release:*",
25
25
  "release:build": "npm run build",
26
- "release:publish": "npx np --omit=dev"
26
+ "release:publish": "np --yolo --no-release-draft"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@battis/eslint-config": "github:battis/eslint-config",