cycloneJS
cycloneJS copied to clipboard
Support all async copying by always returning a promise and always being asynchronous
The idea here would be to implement the following major change to the api:
The result of clone would always be asynchronous and always return a promise.
If a clone is successful, the promise would be resolved with the cloned object. It would be rejected with whatever error occured on failure.
The purpose of this change would be to support all possible clones with the object's specified in the spec, therefore attaining as close to full parity as possible with the W3C algorithm, which would be awesome.
Of course there are also cons.
For one, it would make writing code more complicated. Everything has to be async, whether or not the clone requires them, less we unleash cthulu
For another, the user would either have to ensure their environment supports Promises, or use a polyfill to ensure that they are. It looks like most major browsers natively support them, except of course for the red-headed stepchild of the browser world (which, like most people I know in the field, I could personally care less about), and Opera Mini (who even uses that?).
I'd love some feedback!