Appearance
makeDestructurable
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] = objType Declarations
ts
export function makeDestructurable<T extends Record<string, unknown>, A extends readonly any[]>(obj: T, arr: A): T & A