@branch/optionify
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Optionify

Easily create type-safe options from an array of objects.

Turn this:

const users = [
  {
    name: "John",
    id: 3,
  },
];

const options = users.map((user) => ({
  label: user.name,
  value: user.id,
}));

return <Select options={options} />;

Into this:

import { optionify } from '@branch/optionify'

const users = [
  {
    name: "John",
    id: 3,
  },
];

const options = optionify(users, "name", "id");

return <Select options={options} />;

Readme

Keywords

none

Package Sidebar

Install

npm i @branch/optionify

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

18.1 kB

Total Files

13

Last publish

Collaborators

  • branch