{"_id":"@alfonsofilho/specjs","_rev":"2-0fac195d43ca57472ead8f2b1cf1a92c","name":"@alfonsofilho/specjs","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@alfonsofilho/specjs","version":"0.0.1","description":"Design by contract javascript library","keywords":["contract","offensive","correctness","precondition","postcondition","invariant","test","require","ensure"],"source":"src/specjs.ts","main":"dist/specjs.js","module":"dist/specjs.esm.js","unpkg":"dist/specjs.umd.js","browser":"dist/specjs.umd.js","types":"dist/specjs.d.ts","scripts":{"test":"standardx --fix && tsc --noEmit && jest --coverage","test:watch":"jest --watch","build":"microbundle -i src/specjs.ts -o dist --name SpecJS"},"author":{"name":"Alfonso Filho","email":"alfonsocfilho@gmail.com"},"homepage":"https://github.com/AlfonsoFilho/specjs#readme","bugs":{"url":"https://github.com/AlfonsoFilho/specjs/issues"},"repository":{"type":"git","url":"git+https://github.com/AlfonsoFilho/specjs.git"},"license":"MIT","devDependencies":{"@types/jest":"25.1.4","@typescript-eslint/eslint-plugin":"2.25.0","@typescript-eslint/parser":"2.25.0","jest":"25.2.3","microbundle":"0.12.0-next.8","standardx":"5.0.0","ts-jest":"25.2.1","typescript":"3.8.3"},"eslintConfig":{"rules":{"no-unused-vars":"off","@typescript-eslint/no-unused-vars":"error"}},"standardx":{"parser":"@typescript-eslint/parser","plugins":["@typescript-eslint/eslint-plugin"]},"dependencies":{},"runkitExampleFilename":"examples/example.js","gitHead":"d82c00a88d736d63ff9c93c3634d9753f068ef54","_id":"@alfonsofilho/specjs@0.0.1","_nodeVersion":"10.15.3","_npmVersion":"6.9.0","dist":{"integrity":"sha512-q/CE4hhq3K82smlMetIePzGCvLtPpZV9DaVxOIc9n8aLroH0CcOnDDiNoDxRNdXoMJ9WJPkkLkn8M1mfrtD2jg==","shasum":"0fa444ab12f2e19a65566d0187912601f4cc29dc","tarball":"https://registry.npmjs.org/@alfonsofilho/specjs/-/specjs-0.0.1.tgz","fileCount":17,"unpackedSize":26493,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJegmi/CRA9TVsSAnZWagAAItgP/jIN8/bpvom7K/2x0oKW\nkcAnuZmS/UWT4s/1bQeHMF3gL3Y6yvtQJLJN5Ik1ViSxKvwBm3JH05NLBnp3\ni2L5aGBf4UZEg0DLj8bwDC9bew15HT8qNQv+xgF8g2syYLXo9eZIARnPb63v\nHxeXszfmJLcEuPTPY2RrVju0w7Ga+G17TJ3D2+hnM27kmz7x1R3pNIOYYHsw\nTZhMinvzYHznAB8qzX1GB1TNjggpAykceCcIkaOeSHCdyGzNn6VjSWu3pd4j\nBbiUQzxrmew1xFseUcS+Hz9ab+qFaKoWmnlpfEobJ18OQ+0EHIqBX6NKZV4A\nI43L1yez6RLYXBCWcnp3NxdPeia+1ACTInbbVA+56a86FyvHH0x9Ek48yUtg\nwZII1aHguoDFxlfWiOD5ni+k4zx9JvC5bu7gl8/KozpSMIhzLW/9/zrmT8Te\nH5dTgbJOHP9m818XiUqjX+kKYOGZQWGegC4GTl2fSDUkvB7UdLh+uaywIV6/\niSBgtGCR0LyWFqIia77l7z6V21J6o9NCEgYvkV6Oh7+Sf629lPFjmTJHbmpl\nWV981VSPakR/koq0tEQFnmwwt+o/0HnTgGYNgJMn+wu0SAlYXYhpn959T/Z1\n+e+tnfPBoqL/p+AU4NiFEYgEI2okUki0XNW8kJcxh9eE5kaQoFD6AMkm94R6\nVSwb\r\n=HXba\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDz1VAX5azmIQEN0pwrSZOhFNLNNTtv5eng8w3rZ2DM+AiAlERjIkxqaDF0py8IGVAHy3NNymnSXfENEb6Gak0UT1g=="}]},"maintainers":[{"name":"alfonsofilho","email":"alfonsocfilho@gmail.com"}],"_npmUser":{"name":"alfonsofilho","email":"alfonsocfilho@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/specjs_0.0.1_1585604798664_0.798989484046478"},"_hasShrinkwrap":false},"0.0.2":{"name":"@alfonsofilho/specjs","version":"0.0.2","description":"Design by contract javascript library","keywords":["contract","offensive","correctness","precondition","postcondition","invariant","test","require","ensure"],"source":"src/specjs.ts","main":"dist/specjs.js","module":"dist/specjs.esm.js","unpkg":"dist/specjs.umd.js","browser":"dist/specjs.umd.js","types":"dist/specjs.d.ts","scripts":{"test":"standardx --fix && tsc --noEmit && jest --coverage","test:watch":"jest --watch","build":"microbundle -i src/specjs.ts -o dist --name SpecJS"},"author":{"name":"Alfonso Filho","email":"alfonsocfilho@gmail.com"},"homepage":"https://alfonsofilho.github.io/SpecJS","bugs":{"url":"https://github.com/AlfonsoFilho/specjs/issues"},"repository":{"type":"git","url":"git+https://github.com/AlfonsoFilho/specjs.git"},"license":"MIT","devDependencies":{"@types/jest":"25.1.4","@typescript-eslint/eslint-plugin":"2.25.0","@typescript-eslint/parser":"2.25.0","jest":"25.2.3","microbundle":"0.12.0-next.8","standardx":"5.0.0","ts-jest":"25.2.1","typescript":"3.8.3"},"eslintConfig":{"rules":{"no-unused-vars":"off","@typescript-eslint/no-unused-vars":"error"}},"standardx":{"parser":"@typescript-eslint/parser","plugins":["@typescript-eslint/eslint-plugin"]},"dependencies":{},"runkitExampleFilename":"examples/runkit.js","gitHead":"290fcc5fdc3a7afde233f4cb47cfeea14e78b014","_id":"@alfonsofilho/specjs@0.0.2","_nodeVersion":"10.15.3","_npmVersion":"6.14.4","dist":{"integrity":"sha512-j/cB+sR/hnlCqtXrHLBB8Je5b7hthSX7KoVtaXyh6ryla9VuAoziF+XCUIL4u5/fF7eHht4tmM5SAEzdcCtLZA==","shasum":"69a57953fde1b46df2238f736128ccf2a3715dcf","tarball":"https://registry.npmjs.org/@alfonsofilho/specjs/-/specjs-0.0.2.tgz","fileCount":23,"unpackedSize":62080,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeiLN8CRA9TVsSAnZWagAApgsP/1igxN3lUvE80WHaDwUk\n72c+wgk782OWBygsJW0gNIdTzUMPl8P8GoHZ1uU7jfUY4ZcnJFajmJ2RizN4\n/417hsBcVY9WIYiSt3Wev8PchiNsgPrROjxOhYHGTa85yOoUXPi/Nk9pQZWh\nya/qyiXa2iXhRLoOV/fF42jez2mFFSiVel5QNYQF2Yb8l/rTr6wT5ifD9CND\n41ENTKeAx1q3InZ5+sTDdHW7NIYsZ11nMYRNj6cSGrCoBpX61rZv77/hEk6K\njvTlEx2yVSgvIjrgGeSGv54GTim7kWVvP975GI1zKJTV9jeBswQHMOCQ0Pka\n6UM9d60CEbXrcK5cWjR0aEztmXW1ywOvr+Be0MzKc0swvbMPmxt0jfuWiO9m\nKAATQgD9JthheVaeZuhsmiaPSm/p8BPnZs/eVQ+poLl/VXITvMHKPAYIyYF9\nlQ2OwvMaFzDDfG67dE4cfVlpsOixFBUe0PBpZNJcIKw8P8a8b73dF6g7UvBU\nwH4eW08QUmqU/zUE0oZ+/TgooXTBkB5unYUyTf/vXyGQ1G5msTcQiWK71GfE\ndXIOq+J2YvDMkAzvVNfCaY5JVoJocZW/IQp1VqdulgJyCWXKK37kEA7B++pR\nJQ8YdkCEuava0po70v5OV59ms4KuLuASOvXw0GYnzp8tf3yc2j4f/mq31pIW\nzMZd\r\n=Mgch\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCjDKXtYLci/xwpwVaDWROcpxn6yXmSGZsAmR/Kxvu07wIhAMQhHMk3N0C8+sZeXOrP5oq/3R5PpUUvSuPNGaP0tveB"}]},"maintainers":[{"name":"alfonsofilho","email":"alfonsocfilho@gmail.com"}],"_npmUser":{"name":"alfonsofilho","email":"alfonsocfilho@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/specjs_0.0.2_1586017147682_0.44380339015355763"},"_hasShrinkwrap":false}},"time":{"created":"2020-03-30T21:46:38.429Z","0.0.1":"2020-03-30T21:46:38.770Z","modified":"2022-04-04T12:49:09.019Z","0.0.2":"2020-04-04T16:19:07.804Z"},"maintainers":[{"name":"alfonsofilho","email":"alfonsocfilho@gmail.com"}],"description":"Design by contract javascript library","homepage":"https://alfonsofilho.github.io/SpecJS","keywords":["contract","offensive","correctness","precondition","postcondition","invariant","test","require","ensure"],"repository":{"type":"git","url":"git+https://github.com/AlfonsoFilho/specjs.git"},"author":{"name":"Alfonso Filho","email":"alfonsocfilho@gmail.com"},"bugs":{"url":"https://github.com/AlfonsoFilho/specjs/issues"},"license":"MIT","readme":"# SpecJS\n> Design by contract javascript library\n\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Build Status](https://travis-ci.com/AlfonsoFilho/specjs.svg?branch=master)](https://travis-ci.com/AlfonsoFilho/specjs)\n[![npm version](https://badge.fury.io/js/%40alfonsofilho%2Fspecjs.svg)](https://badge.fury.io/js/%40alfonsofilho%2Fspecjs)\n[![Try match-toy on RunKit](https://badge.runkitcdn.com/%40alfonsofilho%2Fspecjs.svg)](https://npm.runkit.com/%40alfonsofilho%2Fspecjs)\n[![codecov](https://codecov.io/gh/AlfonsoFilho/SpecJS/branch/master/graph/badge.svg)](https://codecov.io/gh/AlfonsoFilho/SpecJS)\n\n> **THIS LIBRARY STILL IN EARLY DEVELOPMENT, IT'S NOT STABLE, AND USAGE IN PRODUCTION IS NOT RECOMMENDED YET.**\n\n[SpecJS](https://github.com/AlfonsoFilho/specjs#readme) is a tiny (≈0.7KB) to implement design by contract in Javascript and Typescript projects. To start learning how to use the library, take a look at the [usage section](#Usage). Afterward you'll find more information in the [examples](./examples) and [reading the tests](./src).\n\n[Try it now](https://npm.runkit.com/%40alfonsofilho%2Fspecjs).\n\n\n## Installation\n#### From NPM\n```sh\n$ npm install @alfonsofilho/specjs --save\n```\nOr yarn:\n```sh\n$ yarn add @alfonsofilho/specjs\n```\nThen import/require the module.\n```javascript\nconst SpecJS = require('@alfonsofilho/specjs');\n// or\nimport { bindSpec } from '@alfonsofilho/specjs';\n```\n\n#### From CDN\nPlace the snippet into your html:\n```html\n<script src=\"https://unpkg.com/@alfonsofilho/specjs@0.0.1/dist/specjs.umd.js\"></script>\n```\n\nThis file is a bundle in the [UMD](https://github.com/umdjs/umd) format. In the browser's environments, the module name is in available in `window.SpecJS`.\n\n\nSee more in [examples](./examples).\n\n## Usage\nMost basic usage:\n```typescript\nimport { Sign, conditions, isRequired, check } from '@alfonsofilho/specjs';\n\n// 1. Write the Contract\nconst toUpperContract = (text: string) => ({\n  pre: conditions(\n    isRequired(text),\n    check(() => text.length > 0)\n  ),\n  post: conditions(\n    check((result: string) => result === text.toUpperCase())\n  )\n})\n\n// 2. Write the function or class\nfunction toUpper(text: string): string {\n  return text.toUppercase(text)\n}\n\n// 3. Bind the implementation and the contract\nconst toUpperSigned = Sign(toUpper, toUpperContract)\n\n// 4. Use the signed function with the runtime\n//    guarantees provided by the contract\ntoUpperSigned('test') === 'TEST' // OK\ntoUpperSigner('') === 'TEST' // Precondition fails\n\n\n```\n\n### Built with\n- [Typescript](https://www.typescriptlang.org/)\n- [Jest](https://facebook.github.io/jest/)\n- [Microbundle](https://github.com/developit/microbundle)\n\n## Other nice JavaScript libraries:\nThere are many interesting projects out there implementing design by contract. [Search more in NPM](https://www.npmjs.com/search?q=design%20by%20contract).\n\n## Learn more about design by contract\n- https://en.wikipedia.org/wiki/Design_by_contract\n- https://www.sciencedirect.com/topics/computer-science/design-by-contract\n- https://www.eiffel.org/doc/solutions/Design_by_Contract_and_Assertions\n- https://www.eiffel.com/values/design-by-contract/\n- https://www.leadingagile.com/2018/05/design-by-contract-part-one/\n- https://www.microsoft.com/en-us/research/project/spec/\n\n## Contributing\n- Improving or correcting the documentation.\n- Translating.\n- Finding bugs\n- Sharing this project.\n- PRs are very welcome.\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Changelog\nSee [CHANGELOG](CHANGELOG.md) file for details.\n","readmeFilename":"README.md"}