Code Monkey home page Code Monkey logo

realistic-structured-clone's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

realistic-structured-clone's Issues

DataCloneError saving an object with a function key

I'm using dexie-observable under node.js through fake-indexeddb. Through a series of events it ends up calling put on an object with a save prototype method, which fails because lodash's isPlainObject returns false:

    } else if (!isPlainObject(input)) {
        // This is way too restrictive. Should be able to clone any object that isn't
        // a platform object with an internal slot other than [[Prototype]] or [[Extensible]].
        // But need to reject all platform objects, except those whitelisted for cloning
        // (ie, those with a [[Clone]] internal method), and this errs on the side of caution
        // for now.

        // Supposed to also handle FileList, ImageData, ImageBitmap, but fuck it
        throw new DataCloneError();
    } else {

According to the structured clone algorithm this should be ok- the object will be duplicated but "The prototype chain does not get walked and duplicated".

For comparison, Chrome's IndexedDB implementation allows the object to be saved.

reference: dexie/Dexie.js#647

Dependent upon two version of typeson

I was wondering about this warning from NPM:

npm WARN [email protected] requires a peer of core-js-bundle@^3.6.4 but none is installed. You must install peer dependencies yourself.

So I checked out where this came from:

$ npm ls typeson
safeex_cloud@ /home/jmk/git/my-project
└─┬ [email protected]
  └─┬ [email protected]
    ├── [email protected] 
    └─┬ [email protected]
      └── [email protected] 

Seemingly, if you upgrade to the newest typeson, this warning will disappear.

Object with zero-length string key results in TypeError

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.

corejs needs updating

hi there!

npm WARN deprecated [email protected]: core-js@<3.4 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
I'm getting it as part of install of another package for which your code is a requirement.

Thanks,
Ben

Blobs

I'm looking at using fake-indexeddb for faster unit testing.

Upon reading the w3c spec, could the blob implementation be just new Blob([blob])? On mdn it doesn't appear that close() is implemented in any browser. Blobs are also immutable so copying the real underlying data isn't necessary. Any thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.