@psimk/typed-object
Advanced tools
Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "@psimk/typed-object", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "typed versions of `Object` property methods", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/psimk/typed-object", |
@@ -15,34 +15,4 @@ # typed-object | ||
There are two ways to use the package: | ||
There are two ways to use the package, importing an "aliased" function with the stricter types already applied or importing just the type and manually casting the built-in methods. Below are examples using both approaches. There is no "best" approach and should be chosen according to your projects standards and requirements. | ||
### functions | ||
Each method has a corresponding function, with the stricter typings already applied. | ||
```ts | ||
import { typedObjectKeys } from "@psimk/typed-object"; | ||
const foo = { a: 1, b: 2, c: 3 }; | ||
Object.keys(foo); // string[] | ||
typedObjectKeys(foo); // Array<"a" | "b" | "c"> | ||
``` | ||
### types | ||
Instead of the above, you can import the types on their own. | ||
```ts | ||
import type { ObjectKeys } from "@psimk/typed-object"; | ||
const foo = { a: 1, b: 2, c: 3 } as const; | ||
Object.keys(foo); // string[] | ||
(Object.keys as ObjectKeys)(foo); // Array<"a" | "b" | "c"> | ||
``` | ||
## API | ||
- **ObjectKeys** | ||
@@ -88,5 +58,5 @@ | ||
typedObjectEntries(foo); // Array<["a", 1] | ["b", 2] | ["c", 4]> | ||
typedObjectEntries(foo); // Array<["a", 1] | ["b", 2] | ["c", 3]> | ||
// OR | ||
(Object.keys as ObjectEntries)(foo); // Array<["a", 1] | ["b", 2] | ["c", 4]> | ||
(Object.keys as ObjectEntries)(foo); // Array<["a", 1] | ["b", 2] | ["c", 3]> | ||
``` | ||
@@ -93,0 +63,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6575
69