{"name":"stampit","version":"3.1.3","description":"Create objects from reusable, composable behaviors.","author":{"name":"Eric Elliott","url":"https://ericelliottjs.com"},"main":"dist/stampit.full.js","jsnext:main":"dist/stampit.mjs","keywords":["object","prototype","object oriented","browser","inheritance","oop","node","factory","class","stamp"],"repository":{"type":"git","url":"git+ssh://git@github.com/stampit-org/stampit.git"},"dependencies":{},"devDependencies":{"babel-cli":"^6.10.1","babel-preset-es2015":"^6.16.0","benchmark":"^2.1.1","check-compose":"^3.2.0","dependency-check":"^2.5.0","eslint":"^3.7.0","eslint-config-airbnb-base":"^11.0.0","eslint-plugin-import":"^2.0.1","istanbul":"^1.1.0-alpha.1","lodash":"^4.16.1","magic-string":"^0.19.0","nsp":"^2.1.0","require-all":"^2.2.0","rimraf":"^2.3.4","rollup":"^0.41.1","rollup-plugin-buble":"^0.15.0","rollup-plugin-filesize":"^1.0.0","rollup-plugin-uglify":"^1.0.0","tape":"^4.2.2","watch":"^1.0.1"},"scripts":{"cov":"npm run cov:clean && npm run cov:generate","cov:clean":"rimraf ./coverage/","cov:generate":"babel-node --presets=es2015 ./node_modules/.bin/istanbul cover test","prepublish":"npm run check","pretest":"npm run build","test":"babel-node --presets=es2015 test && npm run lint","posttest":"node test/benchmark","clean":"rimraf dist/*","lint":"eslint src && eslint test","prebuild":"npm run clean","build":"babel-node --presets=es2015 build","deps":"npm run deps:missing && npm run deps:extra","deps:missing":"dependency-check package.json","deps:extra":"dependency-check package.json --extra --no-dev --ignore","audit":"nsp check","precheck":"npm test","check":"npm run audit && npm run deps","watch":"watch 'clear && npm -s test' test/ src/"},"license":"MIT","npmName":"stampit","npmFileMap":[{"basePath":"/dist/","files":["stampit.full.js","stampit.full.min.js"]}],"gitHead":"3d647c39c136bc947185bab3d5f64476dc12e61f","bugs":{"url":"https://github.com/stampit-org/stampit/issues"},"homepage":"https://github.com/stampit-org/stampit#readme","_id":"stampit@3.1.3","_shasum":"3bdb5f2caffa664089926dd6c0d8a96c167714fb","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.9.1","_npmUser":{"name":"koresar","email":"kore.sar@gmail.com"},"dist":{"shasum":"3bdb5f2caffa664089926dd6c0d8a96c167714fb","tarball":"http://registry-npm.ywwl.com/stampit/download/stampit-3.1.3.tgz","integrity":"sha512-lzwiuqAMTaSGmEKLQ1GTmf0zHwYTTlCaQFMdX8/6FaSV9EcEA8gG2TfpcJ/fhs7TEQESFzRgP1KKpT+pZZjAmw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmyBlKlLePuUGzTG2sdKi9HjSl3Xr+4gOjteMoblswiAIgc3J6k6pRhgqRoAMAHijeiGFT+Iak7lKn9gvLmoB9nP0="}],"size":31198,"noattachment":false,"key":"/stampit/-/stampit-3.1.3.tgz"},"maintainers":[{"name":"koresar","email":"kore.sar@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/stampit-3.1.3.tgz_1493565978966_0.11268983385525644"},"directories":{},"readme":"<p align=\"center\">\n<img src=\"https://raw.githubusercontent.com/stampit-org/stampit-logo/master/stampit-logo.png\" alt=\"stampit\" width=\"160\" />\n</p>\n\n# Stampit [![Build Status](https://travis-ci.org/stampit-org/stampit.svg?branch=master)](https://travis-ci.org/stampit-org/stampit) [![npm](https://img.shields.io/npm/dm/stampit.svg)](https://www.npmjs.com/package/stampit) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/stampit-org/stampit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Twitter Follow](https://img.shields.io/twitter/follow/stampit.svg?style=social&label=Follow&maxAge=2592000)](https://twitter.com/stampit_org) [![UNPKG](https://img.shields.io/badge/gzip%20size-1.4%20kB-brightgreen.svg)](https://unpkg.com/stampit@latest/dist/stampit.min.js)\n\n**Create objects from reusable, composable behaviors** \n\nStampit is a **1.4KB** gzipped (or 3K minified) JavaScript module which supports three different kinds of prototypal inheritance (delegation, concatenation, and functional) to let you inherit behavior in a way that is much more powerful and flexible than any other Object Oriented Programming model.\n\n Stamps are [standardised](https://github.com/stampit-org/stamp-specification) composable factory functions. **Stampit** is a handy implementation of the specification featuring friendly API.\n\nFind many more examples in [this series of mini blog posts](https://medium.com/@koresar/fun-with-stamps-episode-1-stamp-basics-e0627d81efe0) or on the [official website](https://stampit.js.org/api/quick-start).\n\n## Example\n\n```js\nimport stampit from 'stampit'\n\nconst Character = stampit({\n  props: {\n    name: null,\n    health: 100\n  },\n  init({ name = this.name }) {\n    this.name = name\n  }\n})\n\nconst Fighter = Character.compose({ // inheriting\n  props: {\n    stamina: 100\n  },\n  init({ stamina = this.stamina }) {\n    this.stamina = stamina;    \n  },\n  methods: {\n    fight() {\n      console.log(`${this.name} takes a mighty swing!`)\n      this.stamina--\n    }\n  }\n})\n\nconst Mage = Character.compose({ // inheriting\n  props: {\n    mana: 100\n  },\n  init({ mana = this.mana }) {\n    this.mana = mana;    \n  },\n  methods: {\n    cast() {\n      console.log(`${this.name} casts a fireball!`)\n      this.mana--\n    }\n  }\n})\n\nconst Paladin = stampit(Mage, Fighter) // as simple as that!\n\nconst fighter = Fighter({ name: 'Thumper' })\nfighter.fight()\nconst mage = Mage({ name: 'Zapper' })\nmage.cast()\nconst paladin = Paladin({ name: 'Roland', stamina: 50, mana: 50 })\npaladin.fight()\npaladin.cast()\n\nconsole.log(Paladin.compose.properties) // { name: null, health: 100, stamina: 100, mana: 100 }\nconsole.log(Paladin.compose.methods) // { fight: [Function: fight], cast: [Function: cast] }\n```\n\n\n## Status\n\n* **v1**. `npm i stampit@1`\n* **v2**. `npm i stampit@2` [Breaking changes](https://github.com/stampit-org/stampit/releases/tag/2.0)\n* **v3**. `npm i stampit@3` [Breaking changes](https://github.com/stampit-org/stampit/releases/tag/v3.0.0). Compatible with the [stamp specification](https://github.com/stampit-org/stamp-specification) <= 1.4\n* **v4**. `npm i stampit` [Breaking changes](https://github.com/stampit-org/stampit/releases/tag/v4.0.0). Compatible with the [stamp specification](https://github.com/stampit-org/stamp-specification) v1.5\n* **next**. `npm i @stamp/it` The [new ecosystem](https://www.npmjs.com/~stamp/) of useful stamps like collision control, etc.\n\n\n## Install\n\n[![NPM](https://nodei.co/npm/stampit.png?compact=true)](https://www.npmjs.com/package/stampit)\n\n## Compatibility\n\nStampit should run fine in any ES5 browser or any node.js.\n\n## API\n\nSee https://stampit.js.org\n\n\n# What's the Point?\n\nPrototypal OO is great, and JavaScript's capabilities give us some really powerful tools to explore it, but it could be easier to use.\n\nBasic questions like \"how do I inherit privileged methods and private data?\" and \n\"what are some good alternatives to inheritance hierarchies?\" are stumpers for many JavaScript users.\n\nLet's answer both of these questions at the same time.\n\n```js\n// Some privileged methods with some private data.\nconst Availability = stampit({\n  init() {\n    let isOpen = false; // private\n\n    this.open = function open() {\n      isOpen = true;\n      return this;\n    };\n    this.close = function close() {\n      isOpen = false;\n      return this;\n    };\n    this.isOpen = function isOpenMethod() {\n      return isOpen;\n    }\n  }\n});\n\n// Here's a stamp with public methods, and some state:\nconst Membership = stampit({\n  props: {\n    members: {}\n  },\n  methods: {\n    add(member) {\n      this.members[member.name] = member;\n      return this;\n    },\n    getMember(name) {\n      return this.members[name];\n    }\n  }\n});\n\n// Let's set some defaults:\nconst Defaults = stampit({\n  props: {\n    name: \"The Saloon\",\n    specials: \"Whisky, Gin, Tequila\"\n  },\n  init({ name, specials }) {\n    this.name = name || this.name;\n    this.specials = specials || this.specials;\n  }\n});\n\n// Classical inheritance has nothing on this.\n// No parent/child coupling. No deep inheritance hierarchies.\n// Just good, clean code reusability.\nconst Bar = stampit(Defaults, Availability, Membership);\n\n// Create an object instance\nconst myBar = Bar({ name: \"Moe's\" });\n\n// Silly, but proves that everything is as it should be.\nmyBar.add({ name: \"Homer\" }).open().getMember(\"Homer\");\n```\n\nFor more examples see the [API](https://stampit.js.org) or the [Fun With Stamps](https://medium.com/@koresar/fun-with-stamps-episode-1-stamp-basics-e0627d81efe0) mini-blog series.\n\n# Development\n\n### Unit tests\n```\nnpm t\n```\n\n### Unit and benchmark tests\n```\nenv CI=1 npm t\n```\n\n### Unit tests in a browser\nTo run unit tests in a default browser:\n```\nnpm run browsertest\n```\nTo run tests in a different browser:\n* Open the `./test/index.html` in your browser, and\n* open developer's console. The logs should indicate success.\n\n### Publishing to NPM registry\n```bash\nnpx cut-release\n```\nIt will run the `cut-release` utility which would ask you if you're publishing patch, minor, or major version. Then it will execute `npm version`, `git push` and `npm publish` with proper arguments for you.\n","publish_time":1493565980937,"_cnpm_publish_time":1493565980937,"dist-tags":{"latest":"5.1.0","next":"5.0.5-next","rc":"3.0.0-rc.11"}}