main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
676 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import addMapEntry from './_addMapEntry.js';
|
---|
| 2 | import arrayReduce from './_arrayReduce.js';
|
---|
| 3 | import mapToArray from './_mapToArray.js';
|
---|
| 4 |
|
---|
| 5 | /** Used to compose bitmasks for cloning. */
|
---|
| 6 | var CLONE_DEEP_FLAG = 1;
|
---|
| 7 |
|
---|
| 8 | /**
|
---|
| 9 | * Creates a clone of `map`.
|
---|
| 10 | *
|
---|
| 11 | * @private
|
---|
| 12 | * @param {Object} map The map to clone.
|
---|
| 13 | * @param {Function} cloneFunc The function to clone values.
|
---|
| 14 | * @param {boolean} [isDeep] Specify a deep clone.
|
---|
| 15 | * @returns {Object} Returns the cloned map.
|
---|
| 16 | */
|
---|
| 17 | function cloneMap(map, isDeep, cloneFunc) {
|
---|
| 18 | var array = isDeep ? cloneFunc(mapToArray(map), CLONE_DEEP_FLAG) : mapToArray(map);
|
---|
| 19 | return arrayReduce(array, addMapEntry, new map.constructor);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | export default cloneMap;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.