Skip to main content
Module

x/denops_std/function/mod.ts>deepcopy

📚 Standard module for denops.vim
Go to Latest
function deepcopy
import { deepcopy } from "https://deno.land/x/denops_std@v6.4.0/function/mod.ts";

Make a copy of {expr}. For Numbers and Strings this isn't different from using {expr} directly. When {expr} is a List a full copy is created. This means that the original List can be changed without changing the copy, and vice versa. When an item is a List or Dictionary, a copy for it is made, recursively. Thus changing an item in the copy does not change the contents of the original List. A Dictionary is copied in a similar way as a List.

When {noref} is omitted or zero a contained List or Dictionary is only copied once. All references point to this single copy. With {noref} set to 1 every occurrence of a List or Dictionary results in a new copy. This also means that a cyclic reference causes deepcopy() to fail.

Nesting is possible up to 100 levels. When there is an item that refers back to a higher level making a deep copy with {noref} set to 1 will fail. Also see copy().

Can also be used as a method:

GetObject()->deepcopy()

Parameters

denops: Denops
expr: unknown
optional
noref: unknown

Returns

Promise<unknown>