@monstermann/fn
Version:
A utility library for TypeScript.
31 lines (29 loc) • 709 B
JavaScript
import { dfdlT } from "@monstermann/dfdl";
import { cloneMap } from "@monstermann/remmi";
//#region src/map/clone.ts
/**
* `clone(target)`
*
* Creates a shallow copy of a `Map`, unless marked as mutable with `markAsMutable` inside a mutation context (see [@monstermann/remmi](https://michaelostermann.github.io/remmi/#clonearray-array)).
*
* ```ts
* const original = new Map([
* ["a", 1],
* ["b", 2],
* ]);
*
* const copy = clone(original); // Map { 'a' => 1, 'b' => 2 }
* ```
*
* ```ts
* const original = new Map([
* ["a", 1],
* ["b", 2],
* ]);
*
* const copy = pipe(original, clone()); // Map { 'a' => 1, 'b' => 2 }
* ```
*/
const clone = dfdlT(cloneMap, 1);
//#endregion
export { clone };