Skip to content
On this page

makeDestructurable

Category
Last Changed
6 months ago

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

Usage

TypeScript Example:

import { makeDestructurable } from '@vueuse/core'

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

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

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

const obj = makeDestructurable(
  { foo, bar } as const,
  [ foo, bar ] as const,
)

Usage:

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

Type Declarations

export declare function makeDestructurable<
  T extends Record<string, unknown>,
  A extends readonly any[]
>(obj: T, arr: A): T & A
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
makeDestructurable has loaded