Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Map is not cloned when passed as the root object #1

@laurence-myers

Description

@laurence-myers

Reproducible test scenario (using Mocha):

const deepClone = require('fast-deepclone');
const assert = require('assert');

describe(`fast-deepclone`, function () {
    it(`can deep copy a map`, function () {
        const map = new Map();
        map.set('key', 'value');

        const copiedMap = deepClone(map, true);
        assert.notStrictEqual(map, copiedMap, "Variables holding Maps should not reference the same object in memory");
        assert.strictEqual(map.size, copiedMap.size, "The cloned Map should have the same size as the original Map");
    });
});

This test will fail at the assertion "Variables holding Maps should not reference the same object in memory"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions