0.0.4 • Published 1 year ago

typed-helpers v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

typed-helpers

npm CircleCI

Typed utils for TypeScript codebases.

Installation

npm i typed-helpers --save

Usage

typedObject.keys()

import { typedObject } from 'typed-helpers';

const planets = {
  earth: 'Earth',
  mars: 'Mars',
  jupiter: 'Jupiter',
} as const;

const nativeKeys = Object.keys(planets);
// string[]

const typedKeys = typedObject.keys(planets);
// ("earth" | "mars" | "jupiter")[]

typedObject.entries()

import { typedObject } from 'typed-helpers';

const planets = {
  earth: 'Earth',
  mars: 'Mars',
  jupiter: 'Jupiter',
} as const;

const nativeEntries = Object.entries(planets);
// [string, "Earth" | "Mars" | "Jupiter"][]

const typedEntries = typedObject.entries(planets);
// ["earth" | "mars" | "jupiter", "Earth" | "Mars" | "Jupiter"][]

License

Open source under the terms of the MIT License.

Maintained by Diogo Capela.

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago