{"name":"clones","version":"1.0.1","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":"c5b7e336e7e626271f8338276125ed899fc59145","_id":"clones@1.0.1","_shasum":"2c9ba98e0d8200e192c3b9987bfebe26fe9207f3","_from":".","_npmVersion":"2.15.11","_nodeVersion":"4.7.3","_npmUser":{"name":"commenthol","email":"commenthol@gmail.com"},"dist":{"shasum":"2c9ba98e0d8200e192c3b9987bfebe26fe9207f3","tarball":"http://registry-npm.ywwl.com/clones/download/clones-1.0.1.tgz","integrity":"sha512-v1VSn+hRaGAPKJq4gzLFqG4zeUene1cXIahjDbY+dz1x6usTgU8qFDWRit1xRif9D/JWVFJfaRtY2KCV1RGxFw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCHyCoAlLZEzcRNpJj/oUMmMpwsAD9I8Eq5BqU/14NuSkCIQDm24QS5384prblOATSI++TCaFluM+sZjs+sw+8Bpu26w=="}],"size":4140,"noattachment":false,"key":"/clones/-/clones-1.0.1.tgz"},"maintainers":[{"name":"commenthol","email":"commenthol@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/clones-1.0.1.tgz_1487538577923_0.17899220227263868"},"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":1487538579949,"_cnpm_publish_time":1487538579949,"dist-tags":{"latest":"1.2.0"}}