{"_id":"@webreflection/interface","_rev":"5-874c78748adbf8e828c0aa8cf4ddecdc","name":"@webreflection/interface","description":"Simple interfaces for modern JavaScript.","dist-tags":{"latest":"0.1.1"},"versions":{"0.0.0":{"name":"@webreflection/interface","version":"0.0.0","description":"Simple interfaces for modern JavaScript.","main":"interface.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/WebReflection/interface.git"},"keywords":["interfaces"],"author":{"name":"Andrea Giammarchi"},"license":"ISC","bugs":{"url":"https://github.com/WebReflection/interface/issues"},"homepage":"https://github.com/WebReflection/interface#readme","gitHead":"4b1be04634972aa4e1c82a0b8ef4c386358e6a27","_id":"@webreflection/interface@0.0.0","_shasum":"0a9bd910094c78cd4cd640d1cefe44246dd1d2b5","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"webreflection","email":"andrea.giammarchi@gmail.com"},"dist":{"shasum":"0a9bd910094c78cd4cd640d1cefe44246dd1d2b5","tarball":"https://registry.npmjs.org/@webreflection/interface/-/interface-0.0.0.tgz","integrity":"sha512-oJOPl3AiNzZijR23teiQcCTpCKOygqL+mDR+r15eJyFvo3IT9VEXLUf/e3qQ9lqXwyoNxt7EghTvAWqSkx5X5Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC95RC+d0S303+5bw83nbc5Vi9oexp6PLu46iz4i329kgIhAPvxxP6dILmR5EPjiCfIzn2+w0hOnLzErV3UpyuuDDU8"}]},"maintainers":[{"name":"webreflection","email":"andrea.giammarchi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/interface-0.0.0.tgz_1497790619459_0.6283263012301177"}},"0.0.1":{"name":"@webreflection/interface","version":"0.0.1","description":"Simple interfaces for modern JavaScript.","main":"interface.js","scripts":{},"repository":{"type":"git","url":"git+https://github.com/WebReflection/interface.git"},"keywords":["interfaces","interface","implement"],"author":{"name":"Andrea Giammarchi"},"license":"ISC","bugs":{"url":"https://github.com/WebReflection/interface/issues"},"homepage":"https://github.com/WebReflection/interface#readme","gitHead":"84722413896ef1e686154a1247ecaa55ab34a12c","_id":"@webreflection/interface@0.0.1","_shasum":"65090d8bea7a0ef230dd229c95d53a6355500360","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"webreflection","email":"andrea.giammarchi@gmail.com"},"dist":{"shasum":"65090d8bea7a0ef230dd229c95d53a6355500360","tarball":"https://registry.npmjs.org/@webreflection/interface/-/interface-0.0.1.tgz","integrity":"sha512-u5DqfMA5FfTaeTNU09DZqgCri37xJPjvfgESTBazilQcshLL95zJT8KBLMVsllYnkdv0PMP15o2KS71R5CB18Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCOKz6HInJ6EfQRSmA13nsbImgPDFFeFEb7IaxJkg/zhwIhAKGssIZI0joHf2fWsmzzM2HHmkGZXSIi1JNlQi1j8h+d"}]},"maintainers":[{"name":"webreflection","email":"andrea.giammarchi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/interface-0.0.1.tgz_1497811982270_0.7449250076897442"}},"0.1.0":{"name":"@webreflection/interface","version":"0.1.0","description":"Simple interfaces for modern JavaScript.","main":"interface.js","scripts":{"build":"npm run es5 && npm run minify && npm run minify-es5 && npm test && npm run size","coveralls":"cat ./coverage/lcov.info | coveralls","es5":"node es5.js","minify":"uglifyjs interface.js --comments=/^!/ --compress --mangle -o min.js","minify-es5":"uglifyjs interface.es5.js --comments=/^!/ --compress --mangle -o min.es5.js","size":"cat interface.js | wc -c;cat min.js | wc -c;gzip -c min.js | wc -c","test":"istanbul cover test/interface.js","web":"$(sleep 2 && open http://0.0.0.0:7151/) & tiny-cdn run ./"},"repository":{"type":"git","url":"git+https://github.com/WebReflection/interface.git"},"keywords":["interfaces","interface","implement"],"author":{"name":"Andrea Giammarchi"},"license":"ISC","bugs":{"url":"https://github.com/WebReflection/interface/issues"},"homepage":"https://github.com/WebReflection/interface#readme","devDependencies":{"coveralls":"^2.13.1","istanbul":"^0.4.5","tiny-cdn":"^0.7.0","tressa":"^0.3.1","uglify-es":"^3.0.18"},"gitHead":"01e04959dfef14aa0dcbb0d67070689fa5ec58eb","_id":"@webreflection/interface@0.1.0","_shasum":"dd9aeacb14a05dd19c39105a32e0567b5157007b","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"webreflection","email":"andrea.giammarchi@gmail.com"},"dist":{"shasum":"dd9aeacb14a05dd19c39105a32e0567b5157007b","tarball":"https://registry.npmjs.org/@webreflection/interface/-/interface-0.1.0.tgz","integrity":"sha512-IL69uLQy6gITRM4GZgfohIXdiRi4kSOmH1t3CKM1yfqKE0V+ZxstYYcfZjd4vmM5/OUvxIzA9Z3SfUboCmqd1g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGwvCEGCCppZHFiXJ/QW28ERV6210rYp20qXFj8n6K8iAiB1RlhR1YVPqi7/DGAwwHAvP9KqxzJlKHV9rw+OkmSJyA=="}]},"maintainers":[{"name":"webreflection","email":"andrea.giammarchi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/interface-0.1.0.tgz_1497863627387_0.6164867824409157"}},"0.1.1":{"name":"@webreflection/interface","version":"0.1.1","description":"Simple interfaces for modern JavaScript.","main":"interface.js","scripts":{"build":"npm run es5 && npm run minify && npm run minify-es5 && npm test && npm run size","coveralls":"cat ./coverage/lcov.info | coveralls","es5":"node es5.js","minify":"uglifyjs interface.js --comments=/^!/ --compress --mangle -o min.js","minify-es5":"uglifyjs interface.es5.js --comments=/^!/ --compress --mangle -o min.es5.js","size":"cat interface.js | wc -c;cat min.js | wc -c;gzip -c min.js | wc -c","test":"istanbul cover test/interface.js","web":"$(sleep 2 && open http://0.0.0.0:7151/) & tiny-cdn run ./"},"repository":{"type":"git","url":"git+https://github.com/WebReflection/interface.git"},"keywords":["interfaces","interface","implement"],"author":{"name":"Andrea Giammarchi"},"license":"ISC","bugs":{"url":"https://github.com/WebReflection/interface/issues"},"homepage":"https://github.com/WebReflection/interface#readme","devDependencies":{"coveralls":"^2.13.1","istanbul":"^0.4.5","tiny-cdn":"^0.7.0","tressa":"^0.3.1","uglify-es":"^3.0.18"},"gitHead":"5f031e73c557b125790facfd62d81691349e391f","_id":"@webreflection/interface@0.1.1","_shasum":"af2a91daf38179656072a6f92e9f9211658f8566","_from":".","_npmVersion":"4.6.1","_nodeVersion":"8.1.2","_npmUser":{"name":"webreflection","email":"andrea.giammarchi@gmail.com"},"dist":{"shasum":"af2a91daf38179656072a6f92e9f9211658f8566","tarball":"https://registry.npmjs.org/@webreflection/interface/-/interface-0.1.1.tgz","integrity":"sha512-n5t7JLDaLzAPqCWIqC2i+i0RXoxUjXvcpYmTYQ6cR2XyyCL5jTqDh6th21FuZzfi5j+PFvpeYxFPv5b4/vnJzA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCB3AX/oRxzQPkDmBK+iab/xiMcpsyzLmOF9UryGhqCMgIhAI8FyM0wi2WmOMytjzrV2jwe0uWZ67bMJ0C1mE9nyLsq"}]},"maintainers":[{"name":"webreflection","email":"andrea.giammarchi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/interface-0.1.1.tgz_1497949554085_0.3306573948357254"}}},"readme":"# interface [![Build Status](https://travis-ci.org/WebReflection/interface.svg?branch=master)](https://travis-ci.org/WebReflection/interface) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/interface/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/interface?branch=master)\n\nSimple interfaces for modern JavaScript.\n\n`npm -i @webreflection/interface`\n\n### API\nThere are two functions usable through `Object` or any `Function.prototype`:\n\n  * `Object.interface([iFace, ...iFace, ]{object: 'literal'})` to defines left to right interfaces properties on top of the newly created interface\n  * `Object.implements(iFace[, ...iFace])` to create a new object that implements all interfaces (still left to right)\n\nBoth methods can be also used to define classes:\n\n  * `Function.interface([iFace, ...iFace, ]class {})` to defines left to right classes implementing the optional list of previous interfaces as parameters\n  * `class extends AnyClass.implements(iFace[, ...iFace])` to create a new intermediate class that implements all interfaces (still left to right)\n\n\n#### Peculiarities\n\n  * all interfaces properties and symbols are forced as non enumerable\n  * all interfaces are created through the same internal class with a `null` object as prototype\n\nLast point means that objects interfaces do not have toString methods or constructors.\nThese are indeed meant to be used as interfaces only, not as generic objects.\n\n\n### Example\n```js\n// Function.prototype polluted, deal with it!\nrequire('@webreflection/interface');\n\n// an interface is just an object\n// carrying some definition that can be implemented\n// through other objects or classes\nconst EventListener = Object.interface({\n  handleEvent(e) { this['on' + e.type](e); }\n});\n\n// but it can be defined through a class too\n// in such case you can even new EventListener\n// or directly extends EventListener\nconst EventListener = Function.interface(class {\n  handleEvent(e) { this['on' + e.type](e); }\n});\n\n// a simple clicker class (it could directly extends EventListener too)\nclass Clicker {\n  constructor() { super(); this.clicks = 0; }\n  onclick(e) {\n    e.preventDefault();\n    console.log(`You clicked me ${++this.clicks} times`);\n  }\n}\n\n// a BasicClicker that extends Clicker and implements EventListener\nclass BasicClicker extends Clicker.implements(EventListener) {\n  constructor(node) {\n    super();\n    node.addEventListener('click', this);\n  }\n}\n\nnew BasicClicker(document.documentElement);\n```","maintainers":[{"name":"webreflection","email":"andrea.giammarchi@gmail.com"}],"time":{"modified":"2022-06-13T01:37:41.352Z","created":"2017-06-18T12:57:00.462Z","0.0.0":"2017-06-18T12:57:00.462Z","0.0.1":"2017-06-18T18:53:03.143Z","0.1.0":"2017-06-19T09:13:48.263Z","0.1.1":"2017-06-20T09:05:55.046Z"},"homepage":"https://github.com/WebReflection/interface#readme","keywords":["interfaces","interface","implement"],"repository":{"type":"git","url":"git+https://github.com/WebReflection/interface.git"},"author":{"name":"Andrea Giammarchi"},"bugs":{"url":"https://github.com/WebReflection/interface/issues"},"license":"ISC","readmeFilename":"README.md"}