Skip to content

makeDestructurable

Category
Export Size
201 B
Last Changed
last month

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

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

Source

SourceDocs

Contributors

Anthony Fu
SerKo
Breno A
enpitsulin

Changelog

v13.6.0 on
d32f8 - refactor: add @__NO_SIDE_EFFECTS__ annotations to all pure functions (#4907)
v10.10.1 on
842d7 - fix: fix Typescript < 5.0.0 support (#4028)
v10.10.0 on
4ea13 - feat: support parameters without as const (#3971)

Released under the MIT License.

Join the Biggest FREE AI-Driven Development Event for Vue Developers
Save My Seat