{"_id":"coupon-code","_rev":"22-d3267cb0dc3bf004d9f9afbdc0bf3fb2","name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","dist-tags":{"latest":"0.4.5"},"versions":{"0.1.0":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.1.0","author":{"name":"Andrew Chilton","email":"chilts@appsattic.com","url":"http://www.chilts.org/"},"homepage":"https://github.com/appsattic/node-coupon-code","contributors":[],"devDependencies":{"tap":">= 0.0.14"},"dependencies":{},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/appsattic/node-coupon-code.git"},"bugs":{"email":"chilts@appsattic.com","url":"http://github.com/appsattic/node-coupon-code/issues"},"licenses":[{"type":"MIT","url":"https://raw.github.com/appsattic/node-coupon-code/master/LICENSE"}],"keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"tap test/*.js"},"_npmUser":{"name":"chilts","email":"chilts@appsattic.com"},"_id":"coupon-code@0.1.0","_engineSupported":true,"_npmVersion":"1.0.104","_nodeVersion":"v0.6.0","_defaultsLoaded":true,"dist":{"shasum":"2ba153caef53c16202106eb6d7e587b6f6b45840","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.1.0.tgz","integrity":"sha512-eRwd5Va8SIhSXy5221b8GnPeH80KJI43+MpoUXeQdwhJ2LmVqoiWWPpjKUQcPdnVKBO29XWNS+OGJYB5irUxrg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDTVcnmYJ5KzIElDOgbd+FMDGibaPU9a3IXZR2TG6+tzAiEAhRPGcEOhyuNHoO8YGecwPEg+L1lrNCFh5Tz5H6qhSRs="}]},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}]},"0.2.0":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.2.0","author":{"name":"Andrew Chilton","email":"chilts@appsattic.com","url":"http://www.chilts.org/"},"homepage":"https://github.com/appsattic/node-coupon-code","contributors":[],"devDependencies":{"tape":"~2.3.0"},"dependencies":{"xtend":"~2.1.1"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/appsattic/node-coupon-code.git"},"bugs":{"url":"http://github.com/appsattic/node-coupon-code/issues"},"licenses":[{"type":"MIT","url":"https://raw.github.com/appsattic/node-coupon-code/master/LICENSE"}],"keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"tap test/*.js"},"_id":"coupon-code@0.2.0","dist":{"shasum":"24ea92c7dd293238a65f238568977ebec0b24384","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.2.0.tgz","integrity":"sha512-UzquxvwMhoDv0w11JCeIlnlohjZit32DMmKLcUkU4hb2fQCaSTr+/s+NUxB7ycDccbYAxoNrqWbyyOrx5JxaQg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDyvzcNGltrQLt99Yj1AQoQQ7iknpZTZ0QhZqkxbICABQIgVsY61QD07o9JFLN/swC8OF3XQXgteRzi+1uN3zOxK7E="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}]},"0.3.0":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.3.0","author":{"name":"Andrew Chilton","email":"chilts@appsattic.com","url":"http://www.chilts.org/"},"homepage":"https://github.com/appsattic/node-coupon-code","contributors":[],"devDependencies":{"tape":"~2.3.0"},"dependencies":{"xtend":"~2.1.1"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/appsattic/node-coupon-code.git"},"bugs":{"url":"http://github.com/appsattic/node-coupon-code/issues"},"licenses":[{"type":"MIT","url":"https://raw.github.com/appsattic/node-coupon-code/master/LICENSE"}],"keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"set -e; for FILE in test/*.js; do node $FILE; done"},"_id":"coupon-code@0.3.0","dist":{"shasum":"6791361ed153e5fd71720b3127d812c7a9fa189b","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.3.0.tgz","integrity":"sha512-V5WvXOmfkmAkYoFWMGEypKCfZepzc8gdzWD/9kSoO8IyQ81iknX4kD4lrMV02ShX48oUjzyju12VFcZOveeoxg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGnOXr/6A9GMBnIpgPAl8+kd+7seHg8q/+GdnQqy/rNCAiA6ig5dh71d6EI17T7vm6YXV9bG8OECwYjIUK8fQnhaTQ=="}]},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}]},"0.4.0":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.4.0","author":{"name":"Andrew Chilton","email":"chilts@appsattic.com","url":"http://www.chilts.org/"},"homepage":"https://github.com/appsattic/node-coupon-code","contributors":[],"devDependencies":{"tape":"~4.0.0"},"dependencies":{"xtend":"~4.0.0"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/appsattic/node-coupon-code.git"},"bugs":{"url":"http://github.com/appsattic/node-coupon-code/issues"},"licenses":[{"type":"MIT","url":"https://raw.github.com/appsattic/node-coupon-code/master/LICENSE"}],"keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"set -e; for FILE in test/*.js; do node $FILE; done"},"gitHead":"bc577784346dd3b6d6968409444bfaa70863bd1c","_id":"coupon-code@0.4.0","_shasum":"a2f0f8cecbae67a7967a09867cac543896e18f71","_from":".","_npmVersion":"2.8.3","_nodeVersion":"0.10.38","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}],"dist":{"shasum":"a2f0f8cecbae67a7967a09867cac543896e18f71","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.4.0.tgz","integrity":"sha512-t/Gqfyv+sitlQ1F2jOYER5GwR31Uf67T2+MUTeNOnCHC0xq43fMJmTJJt9Pbz/WbxPUIGoHKJwzxT4BbjLjugA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCQ+L80vTEWFD/tJuk6mHQ9qJf9dZirgcv238A7xV6cgQIgfaMlD5MT/T0iUiyt23lsd+YKRTNoByPujzi5s7OabSQ="}]}},"0.4.1":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.4.1","author":{"name":"Andrew Chilton","email":"andychilton@gmail.com","url":"http://chilts.org/"},"homepage":"https://github.com/chilts/node-coupon-code","contributors":[],"devDependencies":{"tape":"~4.0.0"},"dependencies":{"xtend":"~4.0.0"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/chilts/node-coupon-code.git"},"bugs":{"url":"http://github.com/chilts/node-coupon-code/issues"},"licenses":[{"type":"MIT","url":"https://raw.github.com/chilts/node-coupon-code/master/LICENSE"}],"keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"set -e; for FILE in test/*.js; do node $FILE; done"},"gitHead":"adc1489e24f9e0bfa74c3aaf96fdfd74e9b7c987","_id":"coupon-code@0.4.1","_shasum":"0e31553e9f3de7e7c0044bdf27915b5dad1c05e6","_from":".","_npmVersion":"2.8.3","_nodeVersion":"0.10.38","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}],"dist":{"shasum":"0e31553e9f3de7e7c0044bdf27915b5dad1c05e6","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.4.1.tgz","integrity":"sha512-ASk6kA6unGBrwSJUdvZwvHdSi9tFanOhkYJ961Y4ntPGvV5bo7K9oGdvrDy8eXHIuEQN5qMdz5vvw/6SwasPDQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC8gtS8FMFOKZ9wP81uI4/2brjIzUiKc8lU6IDSa4lhVQIhANlxxYcHMkMFElxjIHZpcrLdAqiD0MdeyQFCOUwgSsBf"}]}},"0.4.2":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.4.2","author":{"name":"Andrew Chilton","email":"andychilton@gmail.com","url":"http://chilts.org/"},"homepage":"https://github.com/chilts/node-coupon-code","contributors":[],"devDependencies":{"tape":"~4.0.0"},"dependencies":{"xtend":"~4.0.0"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/chilts/node-coupon-code.git"},"bugs":{"url":"http://github.com/chilts/node-coupon-code/issues"},"licenses":[{"type":"MIT","url":"https://raw.github.com/chilts/node-coupon-code/master/LICENSE"}],"keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"set -e; for FILE in test/*.js; do node $FILE; done"},"gitHead":"b42784a34c3ea10d444f3ec225b0e07b71d0cbbf","_id":"coupon-code@0.4.2","_shasum":"5764d1dffea496fc31334b825ffa5486b0a9d941","_from":".","_npmVersion":"2.9.0","_nodeVersion":"0.10.38","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}],"dist":{"shasum":"5764d1dffea496fc31334b825ffa5486b0a9d941","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.4.2.tgz","integrity":"sha512-Ew5JC1FSJJQJxJcNBmQ0IuWChilO44uUNzm1dG5OT4Q5OcjNXhorLl6s8epFVTZv40YHAt9rTeLj4DFdIY06qg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCfy2LJM93qJGOgBtT6dJWHBNm2T7Uv4CM+U6HfrabbiAIgW2ODEgHtl5O/Gp7stWGyM6G3Lfllk9hPN3XQUAz6ifc="}]}},"0.4.3":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.4.3","author":{"name":"Andrew Chilton","email":"andychilton@gmail.com","url":"http://chilts.org/"},"homepage":"https://github.com/chilts/node-coupon-code","contributors":[],"devDependencies":{"tape":"~4.0.0"},"dependencies":{"xtend":"~4.0.0"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/chilts/node-coupon-code.git"},"bugs":{"url":"http://github.com/chilts/node-coupon-code/issues"},"license":"MIT","keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"set -e; for FILE in test/*.js; do node $FILE; done"},"gitHead":"d366924169ddb2a721657f10f22c98b056f832f0","_id":"coupon-code@0.4.3","_shasum":"145873119d6f1646ceb4ccfb1e3f148d0524168d","_from":".","_npmVersion":"2.9.0","_nodeVersion":"0.10.38","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}],"dist":{"shasum":"145873119d6f1646ceb4ccfb1e3f148d0524168d","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.4.3.tgz","integrity":"sha512-flOiv4rfH7qHFqlZOPLA9mB/zjzBYrEaLExH7QYvwddHPDq0d2yAJwkYiFnQ40Wwhv3xRibQPSFimaQW1NzNfg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCID5w/XnQHnnPc0vgIow5CtOvKtjj+mGxN/FyrnVgz7j2AiEA8gdUdAFKTbM1dJfU4tAR9bEygIRY3lEys7yOTAWPcEU="}]}},"0.4.4":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.4.4","author":{"name":"Andrew Chilton","email":"andychilton@gmail.com","url":"http://chilts.org/"},"homepage":"https://github.com/chilts/node-coupon-code","contributors":[],"devDependencies":{"tape":"~4.0.0"},"dependencies":{"xtend":"~4.0.0"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/chilts/node-coupon-code.git"},"bugs":{"url":"http://github.com/chilts/node-coupon-code/issues"},"license":"MIT","keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"set -e; for FILE in test/*.js; do node $FILE; done"},"gitHead":"c770059f2a2708d1fbfdca189ae5f2dd5d2556f5","_id":"coupon-code@0.4.4","_shasum":"bf19454a1be358136123a93bc26eaf48eb17d93c","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"dist":{"shasum":"bf19454a1be358136123a93bc26eaf48eb17d93c","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.4.4.tgz","integrity":"sha512-KQvaVAVvxS8iePh4NAiTaa/HcTSQhsp08UBHpI8CjWS73c3JMpG/6ka8t4Wu/qCQ1tWB7/wB6nEPW4t4E+x3mw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDdLX8S1zSg9QvoY7ot1wXNQEb0Xfj2IYCiCXAnHNZNYAIgUZosLmucq0MwH51aEH+ucH3ppLnXiNtwb50vz9IQyTY="}]},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/coupon-code-0.4.4.tgz_1471384818089_0.15503863198682666"}},"0.4.5":{"name":"coupon-code","description":"An implementation of Perl's Algorithm::CouponCode for NodeJS.","version":"0.4.5","author":{"name":"Andrew Chilton","email":"andychilton@gmail.com","url":"http://chilts.org/"},"homepage":"https://github.com/chilts/node-coupon-code","contributors":[],"devDependencies":{"tape":"~4.0.0"},"dependencies":{"xtend":"~4.0.0"},"main":"coupon-code.js","engines":{"node":"*"},"repository":{"type":"git","url":"git://github.com/chilts/node-coupon-code.git"},"bugs":{"url":"http://github.com/chilts/node-coupon-code/issues"},"license":"MIT","keywords":["code","token","validation token","verification token","coupon code"],"scripts":{"test":"set -e; for FILE in test/*.js; do node $FILE; done"},"gitHead":"abde336c84b933264bef14d59c1da3f8aa711351","_id":"coupon-code@0.4.5","_shasum":"e8be0567125c8c87abd1da882c2f8a2f9005132a","_from":".","_npmVersion":"2.15.5","_nodeVersion":"4.4.5","_npmUser":{"name":"chilts","email":"andychilton@gmail.com"},"dist":{"shasum":"e8be0567125c8c87abd1da882c2f8a2f9005132a","tarball":"https://registry.npmjs.org/coupon-code/-/coupon-code-0.4.5.tgz","integrity":"sha512-YOJFExqKu/IrJXVIQXWqU8KpbVGGdg5i1FQ45mrYlzp7GIu4yr2qMLot3XzgA9YJbI5GCAIFNkXtQmdoEkbv9Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD0Z/Fh79h0IkmV/8nEY6uugh0a4O9dSf5HwoNh44E2wgIhAKiXQJ1VLAbxCQSmirGbNOi0C3bbNxIs+udGSGFdysLw"}]},"maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/coupon-code-0.4.5.tgz_1479549786967_0.8832340631633997"}}},"readme":"An implementation of Perl's [Algorithm::CouponCode][couponcode] for NodeJS. Thanks to [Grant][grant] for the\ninspiration. :)\n\nNote: this package is considered stable, hence it seems not much is happening, however all bugs get fixed\nand currently no new features are planned. It is done.\n\n# Synopsis #\n\n```\nvar cc = require('coupon-code');\n\n// generate a 3 part code\ncc.generate();\n=> '55G2-DHM0-50NN'\n\n// generate a 4 part code\ncc.generate({ parts : 4 });\n=> 'U5H9-HKDH-8RNX-1EX7'\n\n// generate a code with partLen of 6\ncc.generate({ partLen : 6 });\n=> WYLKQM-U35V40-9N84DA\n```\n\nNow, when someone types their code in, you can check that it is valid. This means that letters like `O`\nare converted to `0` prior to checking.\n\n```\n// same code, just lowercased\ncc.validate('55g2-dhm0-50nn');\n=> '55G2-DHM0-50NN'\n\n// various letters instead of numbers\ncc.validate('SSGZ-DHMO-SONN');\n=> '55G2-DHM0-50NN'\n\n// wrong last character\ncc.validate('55G2-DHM0-50NK');\n=> ''\n\n// not enough chars in the 2nd part\ncc.validate('55G2-DHM-50NN');\n=> ''\n\n// validate a code with 4 parts\ncc.validate('U5H9-HKDH-8RNX-1EX7', { parts : 4 });\n=> U5H9-HKDH-8RNX-1EX7\n\n// validate a code with partLen of 6\ncc.validate('WYLKQM-U35V40-9N84DA', { partLen : 6 });\n=> WYLKQM-U35V40-9N84DA\n```\n\nThe first thing we do to each code is uppercase it. Then we convert the following letters to numbers:\n\n* O -> 0\n* I -> 1\n* Z -> 2\n* S -> 5\n\nThis means [oizs], [OIZS] and [0125] are considered the same code.\n\n# Example #\n\nLet's say you want a user to verify they got something, whether that is an email, letter, fax or carrier pigeon. To\nprove they received it, they have to type the code you sent them into a certain page on your website. You create a code\nwhich they have to type in:\n\n```\nvar cc = require('coupon-code');\n\nvar code = cc.generate();\n=> 55G2-DHM0-50NN\n```\n\nTime passes, letters get wet, carrier pigeons go on adventures and faxes are just as bad as they ever were. Now the\nuser has to type their code into your website. The problem is, they can hardly read what the code was. Luckily we're\nsomewhat forgiving since Z's and 2's are considered the same, O's and 0's, I's and 1's and S's and 5's are also mapped\nto each other. But even more than that, the 4th character of each group is a checkdigit which can determine if the\nother three in that group are correct. The user types this:\n\n```\n[s5g2-dhmo-50nn]\n```\n\nBecause our codes are case insensitive and have good conversions for similar chars, the code is accepted as correct.\n\nAlso, since we have a checkdigit, we can use a client-side plugin to highlight to the user any mistake in their code\nbefore they submit it. Please see the original project ([Algorithm::CouponCode][couponcode]) for more details of client\nside validation.\n\n# Installation\n\nThe easiest way to get it is via [npm][npm]:\n\n``` bash\n$ npm install coupon-code\n```\n\n# Tests\n\nTo run the tests, use npm:\n\n```\n$ npm test\n```\n\n# Author\n\n* Written by [Andrew Chilton](http://chilts.org/blog/)\n* Copyright 2011 [AppsAttic](http://appsattic.com/)\n* Copyright 2013 [Andrew Chilton](http://chilts.org/)\n\n# Inspired By\n\n[Grant McLean](grant)'s [Algorithm::CouponCode][couponcode] - with thanks. :)\n\n# License\n\nMIT.\n\nSee [LICENSE][license] for more details.\n\n[npm]: http://npmjs.org/\n[couponcode]: https://github.com/grantm/Algorithm-CouponCode\n[grant]: http://www.mclean.net.nz/\n[license]: https://raw.github.com/appsattic/node-coupon-code/master/LICENSE\n","maintainers":[{"name":"chilts","email":"chilts@appsattic.com"}],"time":{"modified":"2022-06-14T02:02:42.921Z","created":"2011-11-22T08:34:03.610Z","0.1.0":"2011-11-22T08:34:07.924Z","0.2.0":"2013-12-06T08:29:59.363Z","0.3.0":"2013-12-06T08:36:17.175Z","0.4.0":"2015-05-02T10:10:06.075Z","0.4.1":"2015-05-04T03:08:38.311Z","0.4.2":"2015-05-11T01:43:16.669Z","0.4.3":"2015-05-24T23:12:45.454Z","0.4.4":"2016-08-16T22:00:21.778Z","0.4.5":"2016-11-19T10:03:07.202Z"},"author":{"name":"Andrew Chilton","email":"andychilton@gmail.com","url":"http://chilts.org/"},"repository":{"type":"git","url":"git://github.com/chilts/node-coupon-code.git"},"users":{"leesei":true,"ruffle1986":true,"parkerproject":true,"dylanh724":true,"markthethomas":true,"ga1989":true},"homepage":"https://github.com/chilts/node-coupon-code","keywords":["code","token","validation token","verification token","coupon code"],"contributors":[],"bugs":{"url":"http://github.com/chilts/node-coupon-code/issues"},"readmeFilename":"README.md","license":"MIT"}