{"maintainers":[{"name":"anonymous","email":"iam@alexindigo.com"}],"keywords":["mixin","prototype","inheritance","objects","functions","collection"],"dist-tags":{"latest":"1.0.0"},"author":{"name":"Alex Indigo","email":"iam@alexindigo.com"},"description":"Collection of mixin tools for objects and functions","readme":"# mixly [![NPM Module](https://img.shields.io/npm/v/mixly.svg?style=flat)](https://www.npmjs.com/package/mixly)\n\nCollection of mixin tools for objects and functions.\n\n[![PhantomJS Build](https://img.shields.io/travis/alexindigo/mixly/master.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/mixly)\n[![Linux Build](https://img.shields.io/travis/alexindigo/mixly/master.svg?label=linux:0.10-5.x&style=flat)](https://travis-ci.org/alexindigo/mixly)\n[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/mixly/master.svg?label=windows:0.10-5.x&style=flat)](https://ci.appveyor.com/project/alexindigo/mixly)\n<!-- [![Readme](https://img.shields.io/badge/readme-tested-brightgreen.svg?style=flat)](https://www.npmjs.com/package/reamde) -->\n\n[![Coverage Status](https://img.shields.io/coveralls/alexindigo/mixly/master.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/mixly?branch=master)\n[![Dependency Status](https://img.shields.io/david/alexindigo/mixly.svg?style=flat)](https://david-dm.org/alexindigo/mixly)\n[![bitHound Overall Score](https://www.bithound.io/github/alexindigo/mixly/badges/score.svg)](https://www.bithound.io/github/alexindigo/mixly)\n\n| compression     |    size |\n| :-------------- | ------: |\n| mixly.js        | 8.94 kB |\n| mixly.min.js    | 2.93 kB |\n| mixly.min.js.gz |   964 B |\n\n\n## Table of Contents\n\n<!-- TOC -->\n- [Install](#install)\n- [API](#api)\n  - [mixly](#mixly)\n  - [append](#append)\n  - [chain](#chain)\n  - [copy](#copy)\n  - [extend](#extend)\n  - [funky](#funky)\n  - [immutable](#immutable)\n  - [inherit](#inherit)\n- [License](#license)\n\n<!-- TOC END -->\n\n## Install\n\n```shell\n$ npm install --save mixly\n```\n\n## API\n\n### mixly\n\n_`mixly(object[, object[, ...object]])`_\n\nAlias: _`mixly/mixin`_\n\nCreates prototype chain with the properties from the provided objects, by (shallow) copying own properties from each object onto respective elements in the chain.\n\n```javascript\nvar mixly = require('mixly');\n\nvar o1 = { O1: true, commonThing: 'o1' }\n  , o2 = { O2: true, commonThing: 'o2' }\n  , o3 = { O3: true, commonThing: 'o3' }\n  ;\n\n// (o1) -> (o2) -> (o3)\nvar o0 = mixly(o1, o2, o3);\n\nassert.notStrictEqual(Object.getPrototypeOf(o0), o1, 'Object `o0` does not have prototype set to object `o1`');\nassert.notStrictEqual(Object.getPrototypeOf(o1), o2, 'Object `o1` does not have prototype set to object `o2`');\nassert.notStrictEqual(Object.getPrototypeOf(o2), o3, 'Object `o2` does not have prototype set to object `o3`');\n\nassert.strictEqual(o0.O1, true, 'copied properties from the first object');\nassert.strictEqual(o0.O2, true, 'has access to the properties of the second object');\nassert.strictEqual(o0.O3, true, 'has access to the properties of the third object');\nassert.strictEqual(o0.commonThing, 'o1', 'shared properties from first object \"win\"');\nassert.strictEqual(Object.getPrototypeOf(o0).commonThing, 'o2', 'has access to the shared properties of the second object');\nassert.strictEqual(Object.getPrototypeOf(Object.getPrototypeOf(o0)).commonThing, 'o3', 'has access to the shared properties of the third object');\n\nassert.strictEqual(o0.hasOwnProperty('commonThing'), true, 'has shared properties from first object as own');\nassert.strictEqual(o0.hasOwnProperty('O1'), true, 'has shared properties from first object as own');\nassert.strictEqual(o0.hasOwnProperty('O2'), false, 'does not own properties from the second object');\nassert.strictEqual(o0.hasOwnProperty('O3'), false, 'does not own properties from the third object');\n```\n\nMore details in [test/mixin.js](test/mixin.js) test file.\n\n### append\n\n_`mixly.append(object[, object[, ...object]])`_\n\nAliases: _`mixly/append`_, _`mixly/flat`_\n\nAppends objects' properties (shallow copy) into the first object.\n\n```javascript\nvar append = require('mixly/append');\n\nvar o1 = { O1: true, commonThing: 'o1' }\n  , o2 = { O2: true, commonThing: 'o2' }\n  , o3 = { O3: true, commonThing: 'o3' }\n  ;\n\n// o1 + o2 + o3\nvar oX = append(o1, o2, o3);\n\nassert.strictEqual(oX, o1, 'first argument was modified');\nassert.strictEqual(oX.O1, true, 'kept properties from the first object');\nassert.strictEqual(oX.O2, true, 'obtained properties from the second object');\nassert.strictEqual(oX.O3, true, 'obtained properties from the third object');\nassert.strictEqual(oX.commonThing, 'o3', 'last object in the list overrides shared properties');\n```\n\nMore details in [test/append.js](test/append.js) test file.\n\n### chain\n\n_`mixly.chain(object[, object[, ...object]])`_\n\nAliases: _`mixly/chain`_, _`mixly/proto`_\n\nModifies prototype chain for the provided objects, based on the order of the arguments.\n\n```javascript\nvar chain = require('mixly/chain');\n\nvar o1 = { O1: true, commonThing: 'o1' }\n  , o2 = { O2: true, commonThing: 'o2' }\n  , o3 = { O3: true, commonThing: 'o3' }\n  ;\n\n// o1 -> o2 -> o3\nmixly.chain(o1, o2, o3);\n\nassert.strictEqual(Object.getPrototypeOf(o1), o2, 'Object `o1` has prototype set to object `o2`');\nassert.strictEqual(Object.getPrototypeOf(o2), o3, 'Object `o2` has prototype set to object `o3`');\n\nassert.strictEqual(o1.O1, true, 'kept properties from the first object');\nassert.strictEqual(o1.O2, true, 'has access to the properties of the second object');\nassert.strictEqual(o1.O3, true, 'has access to the properties of the third object');\nassert.strictEqual(o1.commonThing, 'o1', 'kept own shared properties');\nassert.strictEqual(Object.getPrototypeOf(o1).commonThing, 'o2', 'has access to the shared properties of the second object');\nassert.strictEqual(Object.getPrototypeOf(Object.getPrototypeOf(o1)).commonThing, 'o3', 'has access to the shared properties of the third object');\n\nassert.strictEqual(o1.hasOwnProperty('commonThing'), true, 'kept own shared properties');\nassert.strictEqual(o1.hasOwnProperty('O1'), true, 'kept own unique properties');\nassert.strictEqual(o1.hasOwnProperty('O2'), false, 'does not own properties from the second object');\nassert.strictEqual(o1.hasOwnProperty('O3'), false, 'does not own properties from the third object');\n```\n\nMore details in [test/chain.js](test/chain.js) test file.\n\n### copy\n\n_`mixly.copy(object, object)`_\n\nAlias: _`mixly/copy`_\n\nCopies (shallow) own properties between provided objects. _Used internally by other `mixly` methods._\n\n```javascript\nvar copy = require('mixly/copy');\n\nvar o1 = { O1: true, commonThing: 'o1' }\n  , o2 = { O2: true, commonThing: 'o2' }\n  ;\n\n// o1 + o2\nvar oX = copy(o1, o2);\n\nassert.strictEqual(oX, o1, 'first argument was modified');\nassert.strictEqual(oX.O1, true, 'kept properties from the first object');\nassert.strictEqual(oX.O2, true, 'obtained properties from the second object');\nassert.strictEqual(oX.commonThing, 'o2', 'last object in the list overrides shared properties');\n```\n\nMore details in [test/copy.js](test/copy.js) test file.\n\n### extend\n\n_`mixly.extend(function, function)`_\n\nAlias: _`mixly/extend`_\n\nExtends target class with superclass, assigns superclass prototype as prototype of the target class and adds superclass itself as `__proto__` of the target class, allowing \"static\" methods inheritance.\n\n```javascript\nvar extend = require('mixly/extend');\n\nfunction F1()\n{\n  F1.super_.apply(this, arguments);\n  this.p0 += 'd2';\n}\nF1.prototype.p1 = 'f1';\nF1.static1 = true;\n\nfunction F2()\n{\n  this.p0 = 'r2';\n}\nF2.prototype.p2 = 'f2';\nF2.static2 = true;\n\n// F1 -> F2\nextend(F1, F2);\n\nassert.strictEqual('p1' in F1.prototype, false, 'original prototype is gone');\nassert.strictEqual('p2' in F1.prototype, true, 'replaced with new prototype');\n\nassert.strictEqual(F1.static1, true, 'original static property is accessible');\nassert.strictEqual(F1.static2, true, 'extended static property is accessible');\n\n// new instance\nvar f1 = new F1();\n\nassert.strictEqual(f1.p0, 'r2d2', 'constructor executes provided super constructor');\n```\n\nMore details in [test/extend.js](test/extend.js) test file.\n\n### funky\n\n_`mixly.funky(function[, function[, ...function]])`_\n\nAlias: _`mixly/funky`_\n\nCreates prototype chain from the provided functions, by (shallow) copying prototypes from each function onto respective elements in the chain.\n\n```javascript\nvar funky = require('mixly/funky');\n\nfunction F1()\n{\n  this.super_.apply(this, arguments);\n  this.f1 = true;\n}\nF1.prototype.f1p = true;\n\nfunction F2()\n{\n  // this.super_ is reference to itself\n  // we're in the f0 context\n  // don't call super_.super_\n  this.f2 = true;\n}\nF2.prototype.f2p = true;\n\nfunction F3()\n{\n  // never gets here\n  this.f3 = true;\n}\nF3.prototype.f3p = true;\n\n// F0 -> (F1) -> (F2) -> (F3)\nvar F0 = mixly.clone(F1, F2, F3);\nvar f0 = new F0();\n\nassert.notStrictEqual(F0.prototype, F1.prototype, 'is not exactly F1');\nassert.strictEqual(F0.prototype.f1p, true, 'but close');\n\nF0.prototype.bla = 42;\nassert.strictEqual('bla' in F1.prototype, false, 'F1 stays untouched');\n\nassert.strictEqual(f0.f1, true, 'executed F1 constructor');\nassert.strictEqual(f0.f2, true, 'executed F2 constructor');\nassert.strictEqual('f3' in f0, false, 'skipped F3 constructor');\n\nassert.strictEqual(f0.f1p, true, 'inherited F1 prototype properties');\nassert.strictEqual(f0.f2p, true, 'inherited F2 prototype properties');\nassert.strictEqual(f0.f3p, true, 'inherited F3 prototype properties');\n```\n\nMore details in [test/funky.js](test/funky.js) test file.\n\n### immutable\n\n_`mixly.immutable(object[, object[, ...object]])`_\n\nAlias: _`mixly/immutable`_\n\nCreates immutable (shallow) copy of the provided objects. Similar to [`append`](#append), but doesn't modify any of the provided objects.\n\n```javascript\nvar immutable = require('mixly/immutable');\n\nvar o1 = { O1: true, commonThing: 'o1' }\n  , o2 = { O2: true, commonThing: 'o2' }\n  , o3 = { O3: true, commonThing: 'o3' }\n  ;\n\n// oX + o1 + o2 + o3\nvar oX = immutable(o1, o2, o3);\n\nassert.notStrictEqual(oX, o1, 'first argument was not modified');\n\nassert.strictEqual(oX.O1, true, 'kept properties from the first object');\nassert.strictEqual(oX.O2, true, 'obtained properties from the second object');\nassert.strictEqual(oX.O3, true, 'obtained properties from the third object');\nassert.strictEqual(oX.commonThing, 'o3', 'last object in the list overrides shared properties');\n```\n\nMore details in [test/immutable.js](test/immutable.js) test file.\n\n### inherit\n\n_`mixly.inherit(function, function)`_\n\nAlias: _`mixly/inherit`_\n\nAssigns prototype from the superclass to the target class, compatible with node's builtin version (`util.inherit`), but browser-friendly (without browserify magic, i.e. works with other packagers).\n\n```javascript\nvar inherit = require('mixly/inherit');\n\nfunction Child() { Parent.call(this); }\nfunction Parent() {}\n\n// Child -> Parent\ninherit(Child, Parent);\n\n// create instance\nvar child = new Child();\n\nassert.strictEqual(child.constructor.super_, Parent, 'child has reference to the Parent constructor');\nassert.strictEqual(Object.getPrototypeOf(Object.getPrototypeOf(child)), Parent.prototype, 'child has Parent in the prototype chain');\nassert.strictEqual(child instanceof Child, true, 'child instance of Child');\nassert.strictEqual(child instanceof Parent, true, 'child instance of Parent');\n```\n\nMore details in [test/inherit.js](test/inherit.js) test file.\n\n## License\n\nMixly is released under the [MIT](LICENSE) license.\n","repository":{"type":"git","url":"git+https://github.com/alexindigo/mixly.git"},"bugs":{"url":"https://github.com/alexindigo/mixly/issues"},"license":"MIT","versions":{"0.1.0":{"name":"mixly","version":"0.1.0","description":"Mixins for prototype inheritance, works with both objects and functions.","main":"index.js","scripts":{"lint":"eslint *.js test/*.js","test":"nyc --reporter=lcov --reporter=text tape ./test/*.js","posttest":"nyc check-coverage --lines 98 --functions 100 --branches 98","browser":"browserify test/*.js | ghostface | tap-set-exit"},"pre-commit":["lint","test","browser"],"engines":{"node":">= 0.10"},"repository":{"type":"git","url":"git+https://github.com/alexindigo/mixly.git"},"keywords":["mixin","prototype","inheritance","objects","functions"],"author":{"name":"Alex Indigo","email":"iam@alexindigo.com"},"license":"MIT","bugs":{"url":"https://github.com/alexindigo/mixly/issues"},"homepage":"https://github.com/alexindigo/mixly#readme","devDependencies":{"browserify":"^12.0.1","codacy-coverage":"^1.1.3","coveralls":"^2.11.6","eslint":"^1.10.3","ghostface":"^1.5.0","lodash.partialright":"^3.1.1","nyc":"^5.3.0","phantomjs":"^1.9.19","pre-commit":"^1.1.2","reamde":"^1.1.0","tap-set-exit":"^1.1.1","tape":"^4.4.0"},"gitHead":"3b89af121068497c4607590c287e408ccfab3dbd","_id":"mixly@0.1.0","_shasum":"f8edc94a4b564589525ac0517e29df0c1f38de7a","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"anonymous","email":"iam@alexindigo.com"},"dist":{"shasum":"f8edc94a4b564589525ac0517e29df0c1f38de7a","tarball":"http://repository.ncinga.com/nexus/content/groups/npm-all/mixly/-/mixly-0.1.0.tgz","integrity":"sha512-DH4S/XGskf6X9Dn7hfKQP/yfOufYDbvtPLzoEsNLZuJdYBQs6co+1r0LDjiLP3Uj6Fo8aRs294neFA6oVmv4+w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDFLruTMHjNRWDMWWv+zj5I+UlwgKKCla+3bAJMELxCXwIhAOf6auBczbf0Ex3gGNpbzjvGoiD8DI6tV90Kk7BPa8YI"}]},"maintainers":[{"name":"anonymous","email":"iam@alexindigo.com"}]},"0.2.0":{"name":"mixly","version":"0.2.0","description":"Mixins for prototype inheritance, works with both objects and functions.","main":"index.js","scripts":{"lint":"eslint *.js test/*.js","test":"nyc --reporter=lcov --reporter=text tape ./test/*.js | tap-dot","posttest":"nyc check-coverage --lines 98 --functions 100 --branches 98","browser":"browserify test/*.js | ghostface | tap-dot"},"pre-commit":["lint","test","browser"],"engines":{"node":">= 0.10"},"repository":{"type":"git","url":"git+https://github.com/alexindigo/mixly.git"},"keywords":["mixin","prototype","inheritance","objects","functions"],"author":{"name":"Alex Indigo","email":"iam@alexindigo.com"},"license":"MIT","bugs":{"url":"https://github.com/alexindigo/mixly/issues"},"homepage":"https://github.com/alexindigo/mixly#readme","devDependencies":{"browserify":"^13.0.0","codacy-coverage":"^1.1.3","coveralls":"^2.11.6","eslint":"^2.2.0","ghostface":"^1.5.0","nyc":"^5.6.0","phantomjs-prebuilt":"^2.1.4","pre-commit":"^1.1.2","reamde":"^1.1.0","tap-dot":"^1.0.4","tap-nyan":"0.0.2","tape":"^4.4.0"},"gitHead":"2a7ea810346c512bed6e8690bbc9edaea9e14f82","_id":"mixly@0.2.0","_shasum":"a1b3d47d229d051e90aaf424f06788d5f458f986","_from":".","_npmVersion":"2.14.9","_nodeVersion":"0.12.10","_npmUser":{"name":"anonymous","email":"iam@alexindigo.com"},"dist":{"shasum":"a1b3d47d229d051e90aaf424f06788d5f458f986","tarball":"http://repository.ncinga.com/nexus/content/groups/npm-all/mixly/-/mixly-0.2.0.tgz","integrity":"sha512-AVs3ggB0N2WRCjYQrjFYl9qZirQh3PpUyrYBVtGqFxiK8BaESJ9mffa4oCucRWVsCfzbFVtdtEM6oQb2jdMfGA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDB7v8PNwZo+tt14fxy9VIXzk3AEdmkGEC8CNhmlIMDpwIhAKRNXFG/LCy4QxHyDB4NIc2ZcruF3KelLRcuOJ+mHvZv"}]},"maintainers":[{"name":"anonymous","email":"iam@alexindigo.com"}],"_npmOperationalInternal":{"host":"packages-13-west.internal.npmjs.com","tmp":"tmp/mixly-0.2.0.tgz_1456875806086_0.33810046617873013"}},"1.0.0":{"name":"mixly","version":"1.0.0","description":"Collection of mixin tools for objects and functions","main":"index.js","scripts":{"clean":"rimraf coverage","lint":"eslint *.js test/*.js","cover":"istanbul cover --reporter=json tape -- test/*.js | tap-spec","test":"tape test/*.js | tap-spec","browser":"browserify -t browserify-istanbul test/*.js | obake --coverage | tap-spec","report":"istanbul report lcov","size":"browserify index.js | size-table mixly","toc":"toc-md README.md","files":"pkgfiles --sort=name"},"pre-commit":["clean","lint","cover","browser","report","size","toc"],"engines":{"node":">= 0.10"},"repository":{"type":"git","url":"git+https://github.com/alexindigo/mixly.git"},"keywords":["mixin","prototype","inheritance","objects","functions","collection"],"author":{"name":"Alex Indigo","email":"iam@alexindigo.com"},"license":"MIT","bugs":{"url":"https://github.com/alexindigo/mixly/issues"},"homepage":"https://github.com/alexindigo/mixly#readme","devDependencies":{"browserify":"^13.1.0","browserify-istanbul":"^2.0.0","coveralls":"^2.11.12","eslint":"^2.13.1","istanbul":"^0.4.5","obake":"^0.1.2","phantomjs-prebuilt":"^2.1.12","pkgfiles":"^2.3.0","pre-commit":"^1.1.3","reamde":"^1.1.0","rimraf":"^2.5.4","size-table":"^0.2.0","tap-spec":"^4.1.1","tape":"^4.6.0","toc-md":"^0.2.0"},"dependencies":{"fulcon":"^1.0.1"},"gitHead":"83bb69ac59c177767e723c6f6f9c540e285b4a33","_id":"mixly@1.0.0","_shasum":"9b5a2e1f63e6dfba0d30e6797ffae62ab1dc24ef","_from":".","_npmVersion":"2.15.9","_nodeVersion":"4.5.0","_npmUser":{"name":"anonymous","email":"iam@alexindigo.com"},"dist":{"shasum":"9b5a2e1f63e6dfba0d30e6797ffae62ab1dc24ef","tarball":"http://repository.ncinga.com/nexus/content/groups/npm-all/mixly/-/mixly-1.0.0.tgz","integrity":"sha512-ks+xIMVeIDwuYK4LnOMXTfmiEI8oo3tFNFirpHd60C4r2H0wMwKN5/qHCrFBKFK+BYx2Gp7qs+evUJw7QO9D2w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBTCJ+x5bYYoumdlKbYBTnFwCfPJWhsiZr2XyGwMxw07AiEAxCqfBWTgvmCgSCLT9EdvwSzIbH6PvQotxZ6hIRg9mhQ="}]},"maintainers":[{"name":"anonymous","email":"iam@alexindigo.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/mixly-1.0.0.tgz_1472006067666_0.8241378711536527"}}},"name":"mixly","time":{"modified":"2022-06-19T23:02:28.129Z","created":"2016-01-08T22:38:24.588Z","0.1.0":"2016-01-08T22:38:24.588Z","0.2.0":"2016-03-01T23:43:26.642Z","1.0.0":"2016-08-24T02:34:31.411Z"},"readmeFilename":"README.md","homepage":"https://github.com/alexindigo/mixly#readme"}