Socket
Socket
Sign inDemoInstall

@psimk/typed-object

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@psimk/typed-object - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc