{
  "name": "clank",
  "version": "1.0.0",
  "description": "lightweight inheritance and compositional object model; mostly just helpers",
  "main": "index.js",
  "scripts": {
    "test": "mocha -R spec ./test/*.js"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/theporchrat/clank.git"
  },
  "keywords": [
    "inherit",
    "compose",
    "mixin",
    "trait",
    "extend"
  ],
  "author": {
    "name": "@theporchrat Jason Quense"
  },
  "license": "MIT",
  "bugs": {
    "url": "https://github.com/theporchrat/clank/issues"
  },
  "homepage": "https://github.com/theporchrat/clank",
  "devDependencies": {
    "sinon-chai": "^2.5.0",
    "chai": "^1.9.1",
    "sinon": "^1.10.3",
    "mocha": "^1.21.4",
    "gulp-plumber": "^0.6.5",
    "gulp": "^3.8.7",
    "gulp-mocha": "^1.0.0"
  },
  "dependencies": {
    "lodash": "^2.4.1",
    "cobble": "^1.0.0"
  },
  "readme": "Clank\r\n========\r\n\r\nA simple prototypal inheritance abstraction with an emphasis on composition. Clank is a _thin_ wrapper around [cobble](https://github.com/theporchrat/cobble/). If you used Backbone or Ember this API should feel familiar, there is no magic here, just a few wrappers around the normal prototypal inheritance you are used to.\r\n\r\nIt is _highly_ recommended that you take a look at the [tests (`./test/class.js`)](https://github.com/theporchrat/clank/blob/master/test/class.js) for a far more extensive demostration of the functionality of Clank.\r\n\r\n## Browser Support\r\n\r\nWorks fine in IE8 but does expect certain es5 functions, include es5 shim and sham in IE8 and everything will work fine, with a single caveat: object constructors are assigned a non-enumerable property `__META__`, which in IE8 _is_ enumerable, so keep that in mind, when using `Object.assign` and other \"extend\" functions.\r\n\r\n## API\r\n\r\nrequire the module; \r\n\r\n    var Clank = require('clank')\r\n\r\nThe Clank object [is just the cobble function](https://github.com/theporchrat/cobble/#cobbleobjects) with a single new property `.Object` which is your base object.\r\n\r\n## Clank.Object\r\n\r\n### .extend(...spec)\r\n\r\nEvery Constructor returned from `.extend()` also has an extend method.\r\n\r\n    var Human = Clank.Object.extend({ species: 'Homo Sapien' })\r\n    var Jimmy = Human.extend({ name: Jimmy })\r\n\r\n    new Jimmy\r\n\r\nYou can also pass in multiple spec objects and make use of Clanks, underlying use of cobble. \r\n\r\n    var Person = Clank.Object.extend({ species: 'homo sapian', limbs: 4 })\r\n      , docOctMixin = { limbs: 8 }\r\n      , DocOct = Person.extend(docOct, { gender: 'male' });\r\n\r\n    var doc = new DocOct()\r\n    doc.limbs // => 8\r\n\r\nThis effectively means taht you can specify mixin objects before your prototype spec.\r\n\r\nYou can also use cobble's descriptors to handle overrides and super calls. __See the cobble documentation for more information on descriptors__\r\n\r\n    var EnglishSpeaker  = Clank.Object.extend({ greet: function(){ return \"hello\" } })\r\n\r\n    var spanishGreeting = { greet: function(){ return \"hola\" } }\r\n    var germanGreeting  = { greet: function(){ return \"guten morgen\" } }\r\n\r\n    var GermanSpanishAmerican = EnglishSpeaker.extend(spanishGreeting, germanGreeting, { \r\n          greet: Clank.reduce(function (target, next) {\r\n            return function(){\r\n              return target.call(this) + \" and \" + next.call(this)\r\n            }\r\n          }) \r\n        });\r\n\r\n    var person = new GermanSpanishAmerican()\r\n\r\n    person.greet() // => \"hello and hola and guten morgen\"\r\n    \r\n    \r\n    // Super calls with Constructors\r\n    // ---------\r\n    \r\n    var Machine = Clank.Object.extend({\r\n           \r\n           constructor: function(){\r\n             Clank.Object.call(this) //call the super constructor in the traditional way\r\n             \r\n             this.greeting = (this.greeting || '') + 'whizz'\r\n           }\r\n         })\r\n     \r\n    var Toaster = Machine.extend({ \r\n    \r\n          // call the super Toaster constructor after the Toaster constructor using a Descriptor\r\n          constructor: Clank.before(function(){\r\n            this.greeting = 'whorl'\r\n          })\r\n        })\r\n\r\n\r\n### .reopen(...spec)\r\n\r\n`.reopen` is like `.extend` but instead of creating a new Class it alters the current class prototype. Changes made to the prototype will cascade throguh the object heirarchy. \r\n\r\n`.reopen` has the same signature as `.extend`.\r\n\r\n    var Person = Clank.Object.extend({ species: 'homo sapien'})\r\n      , Man    = Person.extend({ gender: 'male' });\r\n\r\n    var man = new Man()\r\n\r\n    man.gender // => 'male'\r\n    man.limbs  // => undefined\r\n    \r\n    Man.reopen({\r\n      limbs: 4,\r\n      gender: 'irrelevant'\r\n    })\r\n\r\n    man.gender // => 'irrelevant'\r\n    man.limbs  // => 4\r\n\r\n\r\n### .create(...properties)\r\n\r\nReturns an instance of the object with instance properties set to the passed in object, or array of objects. `.create` also has the same signature as `.extend()` so you can use descriptors as well to compose properties.\r\n\r\n    var Person = Clank.Object.extend({ greeting: 'guten tag' }); \r\n\r\n    var me  = Person.create({ greeting: 'hello'})\r\n      , friend = Person.create()\r\n\r\n    me.hasOwnProperty('greeting')     // => true\r\n    me.greeting                       // => 'hello'\r\n\r\n    friend.hasOwnProperty('greeting') // => false\r\n    friend.greeting                   // => 'guten tag'\r\n\r\n### Default Object Composition\r\n\r\nIn certain cases you may want to create an object Class with a default composition behaviour when extending or creating instances. Clank provides the `Constructor.setCompositionStrategy(spec)` method for doing just this. The provided `spec` should be an object of `Descriptors` that will be mixed into the instance or extension after all user provided compositions.\r\n\r\n    var Person = Clank.Object.extend({ traits: [ 'biped', 'hair'] });\r\n\r\n    // in the future traits will be concated together\r\n    Person.setCompositionStrategy({\r\n      traits: Clank.concat()\r\n    })\r\n\r\n    var Hero  = Person.extend({ traits: [ 'brave' ] }) //no need to manually resolve this conflict\r\n    \r\n    var  jimmy = new Hero;\r\n\r\n    jimmy.traits // => [ 'biped', 'hair', 'brave' ]\r\n\r\nThis can be very helpful for creating some default behaviour in an often used object, but beware, a user can still provide their own compositions, that run _before_ the default strategy. If the user is unaware of the default strategy this can introduce subtle bugs when they try and duplicate a behaviour.\r\n\r\n## Super Calls\r\n\r\nBy default the descriptors, such as `before()` and `after()`, include super methods and properties, so they are composed together along with any mixins.\r\n\r\n    var Person = Clank.Object.extend({ \r\n          greet: function(name){\r\n            return \"hello\"  + \" \" + name\r\n          }\r\n        }) \r\n\r\n    var Pirate = Person.extend({ \r\n          greet: Clank.compose(function(greeting){\r\n            return  \"ARRRRRRG and \" + greeting \r\n          })\r\n        })\r\n\r\n    var blackBeard = new Pirate()\r\n\r\n    blackBeard.greet('Steven') // => \"ARRRRRRG and hello Steven\"\r\n\r\n\r\nClank _does_ have a \"proper\" `super` implementation but you probably don't need it. The majority of super use-cases, can be solved by simple doing `Parent.prototype[method].call(this, [args]` or by using a Descriptor. Overuse of the super keyword can lead to bad patterns (like calling `_super` in a mixin object), and should be saved for situations when you cannot use a static reference, or you know the super method may change.\r\n\r\nFor a bunch of reasons, using `_super` is going to be less performant than a static reference (either method). __Note: super also makes use of `Function.caller`, a depreciated js feature, internally.__\r\n\r\nIn a few cases where you need to dynamically reference the super class, super han be accessed by `this._super([method]) => returns the method` inside a class method, however, there are a bunch of pitfalls and caveats related to its use, which is why it is __underscored__. Consult the tests for insight into the limitations of this method.\r\n",
  "readmeFilename": "README.md",
  "_id": "clank@1.0.0",
  "_from": "clank@1.0.0"
}
