typed-helpers
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

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.

Package Sidebar

Install

npm i typed-helpers

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

7 kB

Total Files

9

Last publish

Collaborators

  • diogocapela