source: node_modules/ramda/es/clone.js

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 
1import _clone from "./internal/_clone.js";
2import _curry1 from "./internal/_curry1.js";
3/**
4 * Creates a deep copy of the source that can be used in place of the source
5 * object without retaining any references to it.
6 * The source object may contain (nested) `Array`s and `Object`s,
7 * `Number`s, `String`s, `Boolean`s and `Date`s.
8 * `Function`s are assigned by reference rather than copied.
9 *
10 * Dispatches to a `clone` method if present.
11 *
12 * Note that if the source object has multiple nodes that share a reference,
13 * the returned object will have the same structure, but the references will
14 * be pointed to the location within the cloned value.
15 *
16 * @func
17 * @memberOf R
18 * @since v0.1.0
19 * @category Object
20 * @sig {*} -> {*}
21 * @param {*} value The object or array to clone
22 * @return {*} A deeply cloned copy of `val`
23 * @example
24 *
25 * const objects = [{}, {}, {}];
26 * const objectsClone = R.clone(objects);
27 * objects === objectsClone; //=> false
28 * objects[0] === objectsClone[0]; //=> false
29 */
30
31var clone =
32/*#__PURE__*/
33_curry1(function clone(value) {
34 return value != null && typeof value.clone === 'function' ? value.clone() : _clone(value, true);
35});
36
37export default clone;
Note: See TracBrowser for help on using the repository browser.