Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object with zero-length string key results in TypeError #8

Open
paulcyr opened this issue Nov 13, 2020 · 0 comments
Open

Object with zero-length string key results in TypeError #8

paulcyr opened this issue Nov 13, 2020 · 0 comments

Comments

@paulcyr
Copy link

paulcyr commented Nov 13, 2020

Version: 2.0.2

Steps To Reproduce

const realisticStructuredClone = require("realistic-structured-clone");
const sample = {
    "": new Map(),
};
realisticStructuredClone(sample);

The current behavior

The following error is thrown:

TypeError: #<Object> is not iterable
    at new Map (<anonymous>)
    at Object.revive (<redacted>/node_modules/realistic-structured-clone/dist/index.js:1436:16)
    at <redacted>/node_modules/realistic-structured-clone/dist/index.js:1784:156
    at Array.reduce (<anonymous>)
    at _revive (<redacted>/node_modules/realistic-structured-clone/dist/index.js:1783:43)
    at Typeson.c.revive (<redacted>/node_modules/realistic-structure…s/release/async.js:93:12)
    at _drainQueue (<redacted>/node_modules/bluebird/js/release/async.js:86:9)
    at Async.Object.<anonymous>.Async._drainQueues (<redacted>/node_modules/bluebird/js/release/async.js:102:5)
    at Immediate.Async.drainQueues [as _onImmediate] (<redacted>/node_modules/bluebird/js/release/async.js:15:14)
    at runCallback (timers.js:705:18)
    at tryOnImmediate (timers.js:676:5)
    at processImmediate (timers.js:658:5)

The expected behavior

realisticStructuredClone should return an object that with a key of "" and a value that is an empty Map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant