@battis/typescript-tricks 0.4.1 → 0.4.3

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.
@@ -0,0 +1,11 @@
1
+ type EnumObject = {
2
+ [key: string]: number | string;
3
+ };
4
+ type EnumObjectEnum<E extends EnumObject> = E extends {
5
+ [key: string]: infer ET | string;
6
+ } ? ET : never;
7
+ /**
8
+ * @see {@link https://blog.oyam.dev/typescript-enum-values/ How to get an array of enum values in TypeScript}
9
+ */
10
+ export declare function getEnumValues<E extends EnumObject>(enumObject: E): EnumObjectEnum<E>[];
11
+ export {};
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnumValues = void 0;
4
+ /**
5
+ * @see {@link https://blog.oyam.dev/typescript-enum-values/ How to get an array of enum values in TypeScript}
6
+ */
7
+ function getEnumValues(enumObject) {
8
+ return Object.keys(enumObject)
9
+ .filter((key) => Number.isNaN(Number(key)))
10
+ .map((key) => enumObject[key]);
11
+ }
12
+ exports.getEnumValues = getEnumValues;
@@ -0,0 +1,9 @@
1
+ export type JSONValue = string | number | boolean | null | JSONValue[] | {
2
+ [key: string]: JSONValue;
3
+ };
4
+ export interface JSONObject {
5
+ [k: string]: JSONValue;
6
+ }
7
+ export interface JSONArray extends Array<JSONValue> {
8
+ }
9
+ export default JSONValue;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export * from './Constructor';
2
+ export * from './EnumeratedTypes';
2
3
  export * from './Mixin';
3
4
  export * from './PropertyRequirements';
4
5
  export * from './Shorthand';
5
6
  export * from './StaticImplements';
7
+ export * from './JSONValue';
package/dist/index.js CHANGED
@@ -15,7 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./Constructor"), exports);
18
+ __exportStar(require("./EnumeratedTypes"), exports);
18
19
  __exportStar(require("./Mixin"), exports);
19
20
  __exportStar(require("./PropertyRequirements"), exports);
20
21
  __exportStar(require("./Shorthand"), exports);
21
22
  __exportStar(require("./StaticImplements"), exports);
23
+ __exportStar(require("./JSONValue"), exports);
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.4.1",
4
+ "version": "0.4.3",
5
5
  "author": "Seth Battis <seth@battis.net>",
6
6
  "license": "GPL-3.0",
7
7
  "main": "./dist/index.js",