{"name":"clones","version":"1.0.0","description":"should deep clone everything even global objects, functions, circularities, ...","author":{"name":"commenthol","email":"commenthol@gmail.com"},"license":"MIT","main":"lib","jsnext:main":"src","repository":{"type":"git","url":"https://github.com/commenthol/clones.git"},"bugs":{"url":"https://github.com/commenthol/clones/issues"},"keywords":["deep-clone","clone","circular","global"],"engines":{"node":">=4.0.0"},"directories":{"test":"test"},"scripts":{"test":"mocha","karma":"karma start","zuul":"zuul --no-coverage --local 3000 -- test/*.js","lint":"eslint '**/*.js'","transpile":"babel -d lib src","clean":"rimraf lib","dist":"npm run clean && npm run lint && npm run transpile && npm test"},"dependencies":{},"devDependencies":{"babel-core":"^6.23.1","babel-loader":"^6.3.1","babel-preset-es2015":"^6.22.0","karma":"^1.4.1","karma-chrome-launcher":"^2.0.0","karma-coverage":"^1.1.1","karma-firefox-launcher":"^1.0.0","karma-mocha":"^1.3.0","karma-sourcemap-loader":"^0.3.7","karma-spec-reporter":"0.0.26","karma-webpack":"^2.0.2","mocha":"^3.2.0","rimraf":"^2.5.4","webpack":"^2.2.1","zuul":"^3.11.1"},"babel":{"presets":["es2015"]},"gitHead":"a28af6f99c5aefc77a9e0605c73137b1fdbe336b","_id":"clones@1.0.0","_shasum":"32cc534baca27b1faeb8a1c0b3bad224d397fbed","_from":".","_npmVersion":"4.1.2","_nodeVersion":"7.5.0","_npmUser":{"name":"commenthol","email":"commenthol@gmail.com"},"dist":{"shasum":"32cc534baca27b1faeb8a1c0b3bad224d397fbed","tarball":"http://registry-npm.ywwl.com/clones/download/clones-1.0.0.tgz","integrity":"sha512-CIq5JUBMCugnK+Ps6LwaCUWxMrtpQpzjwnCIHSXwtQrxvZ+QiUOjBks/WhAd7sqH+Uz7seQtviJ6iqUvo1xG/g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEu+yGjcHOGwoSRUu6kL804UQESAKZ+RWRMyTBwAfnSTAiBfItCKj4Mxjx+Tgz2jQ3VDMsRSvfP6+9OTYVjg03uDug=="}],"size":3924,"noattachment":false,"key":"/clones/-/clones-1.0.0.tgz"},"maintainers":[{"name":"commenthol","email":"commenthol@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/clones-1.0.0.tgz_1487422256899_0.16788870841264725"},"readme":"# clones\n\n[![NPM version](https://badge.fury.io/js/clones.svg)](https://www.npmjs.com/package/clones/)\n\n> should deep clone everything even global objects, functions, circularities, ...\n\nCompanion for [safer-eval](https://github.com/commenthol/safer-eval).\n\nRuns on node and in modern browsers:\n\n|                | Versions |\n| ---            | ---      |\n| **node**       | ~~0.12~~, 4, 6, 8, 10, 11  |\n| **Chrome**     | 55, 56, 71 |\n| **Firefox**    | 45, 51, 64 |\n| **Edge**       | 14, 16   |\n| **IE**         | ~~11~~   |\n| **Safari**     | 10       |\n| **iOS Safari** | 10       |\n\n## Installation\n\n```\nnpm i -S clones\n```\n\n## Usage\n\n```js\nconst clones = require('clones')\nconst dest = clones(source, [bind])\n```\n\n**Parameters**\n\n**Parameters**\n\n**source**: `Object`, clone source\n\n**bind**: `Object`, bind functions to this context\n\n**Returns**: `Any`, deep clone of `source`\n\n**Example**:\n```js\nconst clones = require('clones')\n\nvar source = {\n  obj: {a: {b: 1}},\n  arr: [true, 1, {c: 'dee'}],\n  fn: function () { return this.number + 12 }\n}\n// adding circularity\nsource.obj.a.e = source.obj.a\n\n// do the cloning (with binding a context)\nvar dest = clones(source, {number: 30})\n// => { obj: { a: { b: 1, e: [Circular] }, d: 2017-02-17T21:57:44.576Z },\n//      arr: [ true, 1, { c: 'dee' } ],\n//      fn: [Function: fn] }\n\n// checks\nassert.ok(dest !== source)                      // has different reference\nassert.ok(dest.obj !== source.obj)              // has different reference\nassert.ok(dest.obj.a !== source.obj.a)          // has different reference\nassert.ok(dest.obj.a.e !== source.obj.a.e)      // different references for circularities\nassert.equal(dest.obj.d.toISOString(),\n  source.obj.d.toISOString())                   // has same content\nassert.ok(dest.fn !== source.fn)                // has different function reference\nsource.fn = source.fn.bind({number: 29})        // bind `this` for `source`\nassert.equal(dest.fn(), source.fn() + 1)        // returning the same result\n```\n\n### Clone prototypes or classes\n\n```js\nconst clones = require('clones')\n// clone built in `Array`\nconst C = clones.classes(Array)\n\nlet c = new C(1,2,3)\n// => [1, 2, 3]\nc.reverse()\n// => [3, 2, 1]\n```\n\n## License\n\n[MIT](./LICENSE)\n","publish_time":1487422257554,"_cnpm_publish_time":1487422257554,"dist-tags":{"latest":"1.2.0"}}