0.0.3 • Published 2 years ago

@branch/optionify v0.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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} />;
0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago