New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cyclonejs

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cyclonejs

A pure-javascript adaptation of the W3C's structured cloning algorithm, designed to provide an easy interface for deep copying of complex objects

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status browser support

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 as File, 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
  • null
  • undefined
  • 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;  // true

Testing

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.

Keywords

FAQs

Package last updated on 04 Jul 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc