{"name":"stampit","version":"4.3.0","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","typings":"./src/stampit.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.1","browserify":"^16.5.0","check-compose":"^5.0.0","eslint":"^6.4.0","gzip-size-cli":"^2.1.0","lodash":"^4.17.15","mkdirp":"^0.5.1","nyc":"^14.1.1","require-all":"^2.2.0","tape":"^4.2.2","uglify-js":"^2.8.29"},"scripts":{"cov":"nyc npm run test","pretest":"npm run build","test":"node test","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,screw_ie8,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":"3e08c442f217e7c961f352838e2aa7b41ad939c4","bugs":{"url":"https://github.com/stampit-org/stampit/issues"},"_id":"stampit@4.3.0","_npmVersion":"6.4.1","_nodeVersion":"8.16.1","_npmUser":{"name":"koresar","email":"kore.sar@gmail.com"},"dist":{"integrity":"sha512-Ea8dBId0WFjmFzd2OO8RPOssNbfBApASwPTMdH83uc2mIQPS0v6JSX0rfvb2cUXIYDarjH5DPpeTA07brAe9cA==","shasum":"0190574151f83280114aa928e96708690359cfaa","tarball":"http://registry-npm.ywwl.com/stampit/download/stampit-4.3.0.tgz","fileCount":4,"unpackedSize":13006,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdfgZ9CRA9TVsSAnZWagAA2/YP/RRl4o2NnNneqWDlb/9B\n2LsjMAUJ54065QOEZER0kbV9rRccUCNOFGakCFovh7DDjxroxgBfO9KfoWOF\n2Xj8D2fO2CQBw5ge1cEh0IUdTdnAfo9nXzBWSUABuch/sOGcEWnEsJnQELm0\n+/9E0Cz5B2nMN+HCWrCx3NaV7Y5WUbgYKLUkxZDIM8htRPx85b1h60s7uk5c\nwvaoOpFwWjfj6/4xmM5ESuUH132eiEY/KxF3qcowZ3q+QyFAy7RxUBstbwr8\nRrqOf+XHnoH2rZ2c/v0whW/OoivSPLbFdou9hg5SmF+l9yDNUZRl88bK197q\nMsocBbIXkCr3HU/v/uZkEq0mnRkg4eXOw6dmbisVWrFGRvaQj3ysF3ReEuji\nuoyKreNN+bl3thOrVLE3QqlKJ6drXI4TRxWTYM9Hh8bOMTvWq46t0Q1hCiEZ\nnUmPbX6W6wdenRTL7z5dgnjsYDR34IJiIJmwc2OFiQweUZttFFIoyTAFykB6\nm/wPg1oMaY6QQHqvNvvFULBYobvJuPuhZdtwzPehoo0e3RWUOvO7MFMfBBGn\nhIaJ0UiE+T+ItpVhftPuK1woC4XOHW8lmn+IaPvp0q17OAwXz+gCPmvG3LA1\nRRbULPHu+WOv8xxGbDtNYwjpfQyCI6pTvkGWiaO1x3X66BdZXI2xeYVDjltl\nrXD8\r\n=zXss\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFhFWxL9086gKRrn8Ss4lUdxKKrsBvuToR8zJkqCFlwqAiAjcTCz4Cqolofbs9ZeHPcKnJH7k4iE5AqYRR7omAvLcA=="}],"size":5753,"noattachment":false,"key":"/stampit/-/stampit-4.3.0.tgz"},"maintainers":[{"name":"koresar","email":"kore.sar@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stampit_4.3.0_1568540284380_0.1856335803925786"},"_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":1568540284511,"_cnpm_publish_time":1568540284511,"dist-tags":{"latest":"5.1.0","next":"5.0.5-next","rc":"3.0.0-rc.11"}}