Function: default()
Updated: 2025-10-10 12:02:04
Polyv Wx Live Player Component
Polyv Wx Live Player Component / modules/super-miniprogram/tool/rfdc / default
Function: default()
default(
opts?): <T>(obj) =>T
Really Fast Deep Clone
Types
rdfc clones all JSON types:
ObjectArrayNumberStringnull
With additional support for:
Date(copied)undefined(copied)Function(referenced)AsyncFunction(referenced)GeneratorFunction(referenced)arguments(copied to a normal object)
All other types have output values that match the output
of JSON.parse(JSON.stringify(o)).
For instance:
const rdfc = require('rdfc')()
const err = Error()
err.code = 1
JSON.parse(JSON.stringify(e)) // {code: 1}
rdfc(e) // {code: 1}
JSON.parse(JSON.stringify(new Uint8Array([1, 2, 3]))) // {'0': 1, '1': 2, '2': 3 }
rdfc(new Uint8Array([1, 2, 3])) // {'0': 1, '1': 2, '2': 3 }
JSON.parse(JSON.stringify({rx: /foo/})) // {rx: {}}
rdfc({rx: /foo/}) // {rx: {}}
Parameters
opts?
Returns
<
T>(obj):T
Type Parameters
T
T
Parameters
obj
T
Returns
T
