Skip to content

makeDestructurable

Category
Export Size
188 B
Last Changed
5 days ago

Make isomorphic destructurable for object and array at the same time. See this blog

Demo

Usage

ts
import { 
makeDestructurable
} from '@reause/shared'
const
foo
= {
name
: 'foo' }
const
bar
= 1024
const
obj
=
makeDestructurable
(
{
foo
,
bar
} as
const
,
[
foo
,
bar
] as
const
,
) // object destructuring const {
foo
:
foo1
,
bar
:
bar1
} =
obj
// array destructuring const [
foo2
,
bar2
] =
obj

Type Declarations

ts
export function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A

Source

Source · Demo

Contributors

hairyf

Changelog

v0.1.0 on
cf125 - fix(shared): resolve makeDestructurable audit findings (#701)
12e08 - feat(shared): add makeDestructurable (#31)

Released under the MIT License. v0.1.8