Skip to content

makeDestructurable

Category
Export Size
364 B
Last Changed
4 years ago

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

Usage

TypeScript Example:

ts
import { makeDestructurable } from '@vueuse/core'

const foo = { name: 'foo' }
const bar = 1024

const obj = makeDestructurable(
  { foo, bar } as const,
  [foo, bar] as const,
)
js
import { makeDestructurable } from '@vueuse/core'
const foo = { name: 'foo' }
const bar = 1024
const obj = makeDestructurable({ foo, bar }, [foo, bar])

Usage:

ts
let { foo, bar } = obj
let [foo, bar] = obj

Type Declarations

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

Source

SourceDocs

Contributors

Anthony Fu

Changelog

No recent changes

Released under the MIT License.

1,000+ devs build with AI. You're next.
Less than 100 seats available. Last chance at this price.
Get access
21
hours
:
14
minutes
:
22
seconds
: