Created
December 5, 2021 22:45
-
-
Save YaronMiro/bfb86aa8ef026a223b790f09787ce837 to your computer and use it in GitHub Desktop.
Clone JS Map - Shallow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const cloneMapShallow = (originalMap) => { | |
return [...originalMap.keys()].reduce( | |
(cloneMap, key) => cloneMap.set(key, originalMap.get(key)), | |
new Map() | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment