UNPKG

938 BJavaScriptView Raw
1var _clone =
2/*#__PURE__*/
3require("./internal/_clone");
4
5var _curry1 =
6/*#__PURE__*/
7require("./internal/_curry1");
8/**
9 * Creates a deep copy of the value which may contain (nested) `Array`s and
10 * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are
11 * assigned by reference rather than copied
12 *
13 * Dispatches to a `clone` method if present.
14 *
15 * @func
16 * @memberOf R
17 * @since v0.1.0
18 * @category Object
19 * @sig {*} -> {*}
20 * @param {*} value The object or array to clone
21 * @return {*} A deeply cloned copy of `val`
22 * @example
23 *
24 * const objects = [{}, {}, {}];
25 * const objectsClone = R.clone(objects);
26 * objects === objectsClone; //=> false
27 * objects[0] === objectsClone[0]; //=> false
28 */
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
37module.exports = clone;
\No newline at end of file