{"name":"stampit","version":"4.3.1","description":"Create objects from reusable, composable behaviors.","author":{"name":"Eric Elliott","url":"https://ericelliottjs.com"},"homepage":"https://stampit.js.org","main":"dist/stampit.min.js","minified:main":"dist/stampit.min.js","types":"./types/index.d.ts","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":{"benchmark":"^2.1.4","browserify":"^16.5.0","check-compose":"^5.0.0","dtslint":"1.0.2","eslint":"^6.6.0","gzip-size-cli":"^3.0.0","lodash":"^4.17.15","mkdirp":"^0.5.1","nyc":"^14.1.1","require-all":"^3.0.0","tape":"^4.11.0","tslint":"^5.20.0","typescript":"^3.6.4","uglify-js":"^3.6.5"},"scripts":{"cov":"nyc npm run test","dtslint":"dtslint test/types","pretest":"npm run build","test":"node test && npm run dtslint","posttest":"node test/benchmark","browsertest":"mkdirp ./dist/ && browserify ./test/index.js > dist/test_bundle.js && cp ./test/index.html ./dist/ && open ./dist/index.html","lint":"eslint ./src/ ./test/","prebuild":"rm -rf ./dist/*","build":"npm run minify","ci":"npm run test","check":"npm run test && npm run lint","minify":"mkdirp ./dist/ && uglifyjs src/stampit.js -c collapse_vars,evaluate=false,ie8=false,unsafe,loops=false,keep_fargs=false,pure_getters,unused,dead_code,keep_fnames=[\"'stampit','Stamp'\"] -m --reserved stampit,Stamp -o dist/stampit.min.js","preversion":"npm run check","postversion":"V=`node -e \"process.stdout.write(require('./package.json').version)\"` && sed s/VERSION/$V/g dist/stampit.min.js > dist/tmp && rm dist/stampit.min.js && mv dist/tmp dist/stampit.min.js","postminify":"ls -l dist/ && echo GZIP size: && gzip-size --raw dist/stampit.min.js"},"license":"MIT","npmName":"stampit","npmFileMap":[{"files":["/src/stampit.js","/dist/stampit.min.js"]}],"eslintConfig":{"env":{"browser":true,"commonjs":true,"es6":true,"node":true},"extends":"eslint:recommended","globals":{"Atomics":"readonly","SharedArrayBuffer":"readonly"},"parserOptions":{"ecmaVersion":2018},"rules":{"no-prototype-builtins":0}},"gitHead":"f6e46841398df23a9e7f36f8784ebd6b4d28f311","bugs":{"url":"https://github.com/stampit-org/stampit/issues"},"_id":"stampit@4.3.1","_nodeVersion":"8.11.4","_npmVersion":"6.10.3","dist":{"integrity":"sha512-pcCXPy7VUXsxKE+oN2xroBmaQRGIIaRSIeD+HICoZb8w9CS5ojGmKPp3OfkXnO4D9UklcKCm9WmkAvAdrrlfZg==","shasum":"90d813671af18f9fc9dcd6816085d7f99174a454","tarball":"http://registry-npm.ywwl.com/stampit/download/stampit-4.3.1.tgz","fileCount":5,"unpackedSize":42007,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd6Dq+CRA9TVsSAnZWagAA3NMQAIoP49OdJMLjjAVR6xfx\naPPnafWIsZEMssQvl3lmCKUoz0jb6tOmk21wh6yEbWE0wgOQJqWdoXznTb7L\neP39ETupQGJFqKHrdPgWRmDJWXWnD9jqsTw4yTJrKTFDTlY1i+xVdPTfaKvT\nUUh3cn6TcJEilXaHA4mKaL2j2C5biJ0N/WanJI+ziRGUWDHmNxzBX5zvxaYm\nUPdOejRcdUkLYu6J+EmWaNN6eaPb6P95p3Yz5k8GYdYyoogHtfplijaImERh\nvNDHuCX6vh5Dh8WF/aMQIo7xBbH0NHy1myiM+TPs+UIO5XBdxEK52Kub980j\n4lIsJ1b0ouldJ+KvrDPldq7RftlM1UW+7kzMhMKuX2lDHbn7TUqEZcDfrIgX\nFlo4BXSni0HseCWFyTiP89d6/HTmDoAIUpKqgSxmJgYQp0eCbXV+OQJfh7Ou\nq+lJaiGJr5fdyx+237JtT73O2vmdanWx4NFRGGBd8scyP/BfAWyb8RkjQbCP\nMfL6gGxQrxi/hoFqsescj0ruvZHH4KLfgJAJxUwtCT2CxIL1niD2O9qfN5Y9\nab1fDbjtRsmJCFEe9elB2WR89MaAvt+J/tEnQzkLi8VrHZUUa2TZv9hBvMrQ\nU6r+9cgXN9ajIy1jpHd5ISYp405h94Mp88XDnPE4tWght6bcMtemA/1O1LfU\nCeIV\r\n=kykO\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCjTLfnSsd0NXwDATzIHzwZjTnZsBU6nAiGvlxhytT1vwIgF7QhNiEX4wQCG/N6aUTNJbcKYSIBkInZrfonOzodHvY="}],"size":9455,"noattachment":false,"key":"/stampit/-/stampit-4.3.1.tgz"},"maintainers":[{"name":"koresar","email":"kore.sar@gmail.com"}],"_npmUser":{"name":"koresar","email":"kore.sar@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stampit_4.3.1_1575500478460_0.580875616855121"},"_hasShrinkwrap":false,"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":1575500478619,"_cnpm_publish_time":1575500478619,"dist-tags":{"latest":"5.1.0","next":"5.0.5-next","rc":"3.0.0-rc.11"}}