main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | var _clone =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./internal/_clone.js");
|
---|
4 |
|
---|
5 | var _curry1 =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./internal/_curry1.js");
|
---|
8 | /**
|
---|
9 | * Creates a deep copy of the source that can be used in place of the source
|
---|
10 | * object without retaining any references to it.
|
---|
11 | * The source object may contain (nested) `Array`s and `Object`s,
|
---|
12 | * `Number`s, `String`s, `Boolean`s and `Date`s.
|
---|
13 | * `Function`s are assigned by reference rather than copied.
|
---|
14 | *
|
---|
15 | * Dispatches to a `clone` method if present.
|
---|
16 | *
|
---|
17 | * Note that if the source object has multiple nodes that share a reference,
|
---|
18 | * the returned object will have the same structure, but the references will
|
---|
19 | * be pointed to the location within the cloned value.
|
---|
20 | *
|
---|
21 | * @func
|
---|
22 | * @memberOf R
|
---|
23 | * @since v0.1.0
|
---|
24 | * @category Object
|
---|
25 | * @sig {*} -> {*}
|
---|
26 | * @param {*} value The object or array to clone
|
---|
27 | * @return {*} A deeply cloned copy of `val`
|
---|
28 | * @example
|
---|
29 | *
|
---|
30 | * const objects = [{}, {}, {}];
|
---|
31 | * const objectsClone = R.clone(objects);
|
---|
32 | * objects === objectsClone; //=> false
|
---|
33 | * objects[0] === objectsClone[0]; //=> false
|
---|
34 | */
|
---|
35 |
|
---|
36 |
|
---|
37 | var clone =
|
---|
38 | /*#__PURE__*/
|
---|
39 | _curry1(function clone(value) {
|
---|
40 | return value != null && typeof value.clone === 'function' ? value.clone() : _clone(value, true);
|
---|
41 | });
|
---|
42 |
|
---|
43 | module.exports = clone; |
---|
Note:
See
TracBrowser
for help on using the repository browser.