Package Exports
- cyclonejs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (cyclonejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Cyclone is an attempt to implement an adaptation of the HTML5 Structured Cloning Algorithm.
It is meant to be:
- Synchronous
- Agnostic to the JS environment (doesn't rely on
postMessage(),replaceState(), etc), and therefore agnostic to types such asFile,Blob, etc (which also allows it to be synchronous in the first place). - Serve the majority of use cases out of the box, but also provide a mechanism to be extensible (coming soon).
- Able to copy functions (including function objects) by reference. This is the only property that's copied by reference. See above about serving the majority of use cases.
- Able to copy DOM objects via
cloneNode
It can handle objects containing:
- Primitives
nullundefined- Number objects
- String objects
- Boolean objects
- Date objects
- RegExp objects
- Array objects
- Object (or "plain") objects
- In most cases, Objects instantiated with the use of a custom constructor (e.g.
function Foo() { this.bar = 'baz' }; var cloneable = new Foo();) - Cyclic references to itself, including nested cyclic references
- Cyclic references to objects within itself, including nested cyclic references to those objects
- DOM Objects
Usage
var o = {
date: new Date(),
number: Math.random()
};
o.self = o;
o.tricky = { self: o };
var c = CY.clone(o);
c === o; // false
c.date === o.date; // false
+(c.date) === +(o.date); // true
c.number === o.number; // true
c.self === c; // true
c.tricky.self === c; // trueTesting
First install the module
$ git clone https://github.com/traviskaufman/cycloneJS.git
$ cd /path/to/cycloneJS
$ npm install .Then just run npm test within the module's directory.
Coming Soon
- Ability to define your own protocols for copying unsupported and/or custom objects.
- Features other people contribute.

