Skip to content

Commit

Permalink
Map generics
Browse files Browse the repository at this point in the history
  • Loading branch information
ogroppo committed Nov 21, 2023
1 parent 00b1ef5 commit 6c1b74c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# deverything

## 0.37.0

### Minor Changes

- map generics

## 0.36.0

### Minor Changes
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Checks are functions that throw an error, if the validation fails

-`checkEnvVars()` Make sure env vars are set per-environment

### TypeScript Helpers
### TypeScript Helpers & Generics

- `Coords`
- `DateLike`
Expand All @@ -164,10 +164,19 @@ Checks are functions that throw an error, if the validation fails
- `MaybePromiseOrValueArray<>`
- `NonUndefined`
- `ObjectKey<>`
- `ObjectKeys<>`
- `ObjectValue<>`
- `PlainObject`
- `ObjectValues<>`
- `ObjectEntries<>`
-`PlainObject` use this instead of `Record<,>` or `extends object`, also makes sure it's not an array
- `Point`
- `PrismaSelect<>`
- `HashMap<>`
- `HashMapKey`
- `NumberMap`
- `StringMap`
- `BoolMap`
- `TrueMap`

## Development

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "deverything",
"version": "0.36.0",
"version": "0.37.0",
"description": "Everything you need for Dev",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
7 changes: 7 additions & 0 deletions src/types/HashMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// I don't like the Dict keyword, but it's a possibility...
export type HashMapKey = string | number | symbol;
export type HashMap<T> = Record<HashMapKey, T>;
export type NumberMap = Record<HashMapKey, number>;
export type StringMap = Record<HashMapKey, string>;
export type BoolMap = Record<HashMapKey, boolean>;
export type TrueMap = Record<HashMapKey, true>;
6 changes: 4 additions & 2 deletions src/types/Object.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export type ObjectValue<T> = T[keyof T];
export type ObjectValues<T> = ObjectValue<T>[];
export type ObjectKey<T> = keyof T;
export type ObjectKeys<T> = ObjectKey<T>[];
export type ObjectValue<T> = T[keyof T];
export type ObjectValues<T> = ObjectValue<T>[];
// ObjectEntry needed?
export type ObjectEntries<T> = { [K in keyof T]: [K, T[K]] }[keyof T][];
1 change: 1 addition & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from "./Coords";
export * from "./Date";
export * from "./Dimensions";
export * from "./HashMap";
export * from "./Matrix";
export * from "./Maybe";
export * from "./NonUndefined";
Expand Down

0 comments on commit 6c1b74c

Please sign in to comment.