{"_id":"@aaronflower/jtils","_rev":"3-aa2a1dc9a44992263e7af14d086f9451","name":"@aaronflower/jtils","dist-tags":{"latest":"0.0.3"},"versions":{"0.0.1":{"name":"@aaronflower/jtils","version":"0.0.1","description":"A javascript utility tools.","main":"index.js","scripts":{"build:cjs":"cross-env BABEL_ENV=cjs babel src/index.js --out-file dist/jtils.cjs.js","test":"echo \"Error: no test specified\" && exit 1"},"author":"","license":"ISC","devDependencies":{"@babel/cli":"^7.2.3","@babel/core":"^7.2.2","@babel/preset-env":"^7.2.3","@babel/register":"^7.0.0","babel-register":"^6.26.0","cross-env":"^5.2.0","editorconfig-cli":"^0.2.1","eslint":"^5.12.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.1","mocha":"^5.2.0","prettier":"^1.15.3"},"gitHead":"c12864cf5e1bab7fa806fc7be0e270ab67402078","_id":"@aaronflower/jtils@0.0.1","_npmVersion":"6.5.0","_nodeVersion":"10.14.2","_npmUser":{"name":"aaronflower","email":"haojunzhan@gmail.com"},"dist":{"integrity":"sha512-Jf7nBPFLXhd51zeBAhB5n8cXhYqO19K1I47obXJsso3teloHAppFcvw6wpzmaqJxsbMqEphFkKH4dmZE7hngaQ==","shasum":"0046c74521b3c7d56697a34e68c0f6d0027dc43c","tarball":"https://registry.npmjs.org/@aaronflower/jtils/-/jtils-0.0.1.tgz","fileCount":13,"unpackedSize":126783,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcPJN5CRA9TVsSAnZWagAARawP/A1qf5r9d+KTYUpOsHkZ\nCAfx7yy8QDLB2BbVc5eNTKmiL2DGW+xHVkllFgbgEM3YOVhDfupYqIqVbNZL\nMxfslZT43TTo/kqYNc6OacVQM5KEEyIF8NvsOs//MuHScWA24bKll0igKt/o\nPga73ZGzx/gvNU33POpA6hWQSJAkbLzptA7QmABCtjJYLHNn5VcPwFOatlTw\n2ZXJAiDjR2uUB3EwtZ08uY3T1thrA1USk+d7PuXGKXD2vQ2xVHdoab61SSRW\nEmusm+BPHisedi08CO9ATgvwf6UqG4fjZ2IGZaRDElBLUt24KB769+zZkBNb\n7W3HlGKFKb/vm6nZkpLDYYenRrX9aWFEJzhSKK05f7SmAaH8cCeGpqJ1xGuX\n7l3ag/KAeVFWNfiW+C6rsE63bpt69xdnW35YEpThKWVOs1W6JClj0HfMzXY2\npZmpXTVbmo/C+pcj0YFDGrxcX1l/UrKThvZzsbJzrp4SMsDfv4wpQ1RWNViN\nFISWbI0NrhK6Gu2qH7hL4RyJeP/0dQRdotKY4qhr8whJzpLtOtXh61BNBFkd\nWSjT4wWWzwdifEVDlaIlVvXzFTbNU+y1pvFtTJnoxXi38YRmGpgRjxqtPSIQ\nYaMyeUGmGRNw+EqfXLLE3Hyq9yKKnNCJK/VYrWVPDvRjNZZAxZPbmHQLepqr\ndz+R\r\n=Br23\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCOaxanA1+5WR3svgOadMBQl155tlTCm35/9hOSIHNwrwIgSpeNExpAwwWPr/6vfWBXJ9udyjiZkXA14pI1r8MtPUQ="}]},"maintainers":[{"name":"aaronflower","email":"haojunzhan@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jtils_0.0.1_1547473784581_0.7845403575191543"},"_hasShrinkwrap":false},"0.0.2":{"name":"@aaronflower/jtils","version":"0.0.2","description":"A javascript utility tools.","main":"dist/jtils.cjs.js","scripts":{"build:cjs":"cross-env BABEL_ENV=cjs babel src/index.js --out-file dist/jtils.cjs.js","test":"echo \"Error: no test specified\" && exit 1","pre-publish":"npm build:cjs"},"repository":{"type":"git","url":"git+https://github.com/AaronFlower/jtils.git"},"author":{"name":"aaronflower"},"license":"ISC","devDependencies":{"@babel/cli":"^7.2.3","@babel/core":"^7.2.2","@babel/preset-env":"^7.2.3","@babel/register":"^7.0.0","babel-register":"^6.26.0","cross-env":"^5.2.0","editorconfig-cli":"^0.2.1","eslint":"^5.12.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.1","mocha":"^5.2.0","prettier":"^1.15.3"},"gitHead":"18738aceafa9080a317b8c28bf0ecdd8d069120b","bugs":{"url":"https://github.com/AaronFlower/jtils/issues"},"homepage":"https://github.com/AaronFlower/jtils#readme","_id":"@aaronflower/jtils@0.0.2","_npmVersion":"6.5.0","_nodeVersion":"10.14.2","_npmUser":{"name":"aaronflower","email":"haojunzhan@gmail.com"},"dist":{"integrity":"sha512-FdNFqhVkI0mDu2KSYg8CR/psR7Pj4Mz76FR3Ctl306+SUcZlGFvcz0MAvzuiAuLMKl8mW1xYTvCdeCai2IZR9g==","shasum":"1ebb165674830745db457691bf9a12031ecfbf32","tarball":"https://registry.npmjs.org/@aaronflower/jtils/-/jtils-0.0.2.tgz","fileCount":2,"unpackedSize":4939,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcPJewCRA9TVsSAnZWagAAee4QAIUNMMhML2Rqvv00J52/\nEEVXW+0s4FAJVILUYdD/MHTqFt03JRi+4HOM2cvObl2ZvbLzDmpJwq34LNkj\nKVCdJxIh1lAj6W7Fgr73AoJHZOjPI7X0EaPpELKvyL3ZonerT5/O0OYTAQhE\n9Rs6Y3wUFwCqdRoWAwgoc6qzoccErzzj9aVGjcPbugGRccbofdbE4eKQGBH1\nVLzTU6VhB7Ali5QQauWpdaAXaNAN8WXRXWBKDRgZf1e9X8/odHRwJXGEsk6k\nvgIIV6plWS44wDVlIXqr8Ksu+4BZjSe2ejCGH1oIdqYJXAdiWK9RQoOMxGdK\nAyPV2beLsWPQA1aWPyUDdQVsjf4bhDx7BNlPn+7ohSjBSUP2ZJzFhjmaDk/z\nCqXmSrRPqhtwPOcFZVQX0gyPSqVIxnAsLpYoerulg54JdGjmmpCC4mbjnjUm\n2V5qiUJmi8eQIXCJvFxhiHe3/Gg2YYw5KM1xLY/Au9rE3D+ofuPa52xwAbPm\nIriClSmNM5Xi2kLJBNkaR3oFOI0vHpeky+PrkyyWGamIfmgzkDDwCo30bFUB\n8HTWTAFFaHKl91gB1tNL6Xuj8LF+hKpUrBVwUBpivbhK4P5RiH2KVzB52UpF\npuQDr/uuxOpyEF/be9UzH8ZQIvq6ry50A8ufutQPwBgJ0Mh8O795APLu3wL2\nOepT\r\n=iIM/\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG3JaIhD8kdDRxLBmHlLMz1JdCnSUDOl65n/po/P0pI9AiBbIvR9hhCa2q+jNjwgihOWwvxvkltYE76JbG8nV8dfRg=="}]},"maintainers":[{"name":"aaronflower","email":"haojunzhan@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jtils_0.0.2_1547474863776_0.8103253938182036"},"_hasShrinkwrap":false},"0.0.3":{"name":"@aaronflower/jtils","version":"0.0.3","description":"A javascript utility tools.","main":"dist/jtils.cjs.js","scripts":{"build:cjs":"cross-env BABEL_ENV=cjs babel src/index.js --out-file dist/jtils.cjs.js","test":"echo \"Error: no test specified\" && exit 1","prepare":"npm run build:cjs"},"repository":{"type":"git","url":"git+https://github.com/AaronFlower/jtils.git"},"author":{"name":"aaronflower"},"license":"ISC","devDependencies":{"@babel/cli":"^7.2.3","@babel/core":"^7.2.2","@babel/preset-env":"^7.2.3","@babel/register":"^7.0.0","babel-register":"^6.26.0","cross-env":"^5.2.0","editorconfig-cli":"^0.2.1","eslint":"^5.12.0","eslint-config-prettier":"^3.3.0","eslint-plugin-prettier":"^3.0.1","mocha":"^5.2.0","prettier":"^1.15.3"},"gitHead":"5f3e01b46789f6e124b6a74d42d4e1975bfca3c8","bugs":{"url":"https://github.com/AaronFlower/jtils/issues"},"homepage":"https://github.com/AaronFlower/jtils#readme","_id":"@aaronflower/jtils@0.0.3","_npmVersion":"6.5.0","_nodeVersion":"10.14.2","_npmUser":{"name":"aaronflower","email":"haojunzhan@gmail.com"},"dist":{"integrity":"sha512-SbBd4GDZP8AmvVrpVThiaZIt+gsmrskEazt0PcGiHQM58vKxKFIUFQ+zYWCzZ7aYI6414xsjsbuMMbyUVoueWg==","shasum":"4536b6ee27cd1de8d86be99051d2fdae9b158c51","tarball":"https://registry.npmjs.org/@aaronflower/jtils/-/jtils-0.0.3.tgz","fileCount":3,"unpackedSize":5474,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcPJjtCRA9TVsSAnZWagAA0LgP/j18lnwLA95E0XUR6bGZ\nEfFYobTL2ctScXo5nOYu40RBvZXdR818fK9OIv/qaligZingWHnOYaHekSRd\niGKwa+aDzSRWBy4c5CfuIPvzBAI2qT2c80fg5oHTxPOteoK7lM5Iqpg+CtSO\nv7kDWYsxGZL5MvF5N2770Q9bNpJ5nXiK/dKRQDes3a90ez1cEmwjbNwf62sM\nkvEIjUHbqWwcTkNvPUYtTJB3pj79hbDGY7X56/X9alR/8/wvAXBMIUkpZxI/\nf1QdkBdLsuoGtdFhBO3lpFSQIEpmncyHhCAL9Fm+lONZDvxxhqDjtj3eW/a7\n/dvrgn4OeZ34/scJUlX9C1n++kHZ42oj+LVxugDCiket9uxOh7gIozb7w8Si\nvAaqK420in9Oy1j1tjrmfHDbJMsyt2FhAAlInVBXyrr2y+dVEGP5jeZfHxH4\nxPdEuNw+AdbRfYp5eOEXfR7BxU2SyVLHEDSoFbpN0QumlC4tVdi2gTqBq4gH\ncpLRjH2YXEYKI6HcyW0IjQTqVvZj7ERiediK4ohfTUXZ4QhRLpqzxBdrpxX7\n+WRzcRM0SwfMhavkzc3yu40f1hWmRAQE7gKgw0/G1JEpEy1iqGlInHd1Vf8m\nV8W9JOm3fJXDUM2i0ug1U54kwXOp+pQRe6L208W3/DrZc77SLpn8/1rCsCIh\n6AGZ\r\n=r51j\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDwYHKoavvN5+fYagWQueVmQdqSkjqYoutHjyqoaRRDvQIgJgji3xJ/Xso6Ikxgm7e8bBYFd8QOb+ST0q0zHT4uXl0="}]},"maintainers":[{"name":"aaronflower","email":"haojunzhan@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jtils_0.0.3_1547475181307_0.3097779214905727"},"_hasShrinkwrap":false}},"time":{"created":"2019-01-14T13:49:44.420Z","0.0.1":"2019-01-14T13:49:44.737Z","modified":"2022-04-04T10:55:37.715Z","0.0.2":"2019-01-14T14:07:43.844Z","0.0.3":"2019-01-14T14:13:01.445Z"},"maintainers":[{"name":"aaronflower","email":"haojunzhan@gmail.com"}],"description":"A javascript utility tools.","license":"ISC","readme":"## JTils\n\n1. Init the project, be careful of your version.\n```bash\nnpm init\n```\n\n2. Hierarchy the project, ignore node_modules\n\n```\n$ mkdir src test\n$ touch .gitignore\n```\n\n3. Add EditorConfig Support\n```\n$ yarn add --dev editorconfig-cli\n$ npx ec init\n```\n\n4. Add ESLint, Prettier support\n```\n$ yarn add --dev eslint\n$ npx eslint --init\n$ yarn add --dev eslint-plugin-prettier eslint-config-prettier\n# add .eslintrc.js .prettierrc.js config file to support.\n```\n\n5. Add a utility function sum.js in src\n```javascript\nexport default function sum (a, b) {\n  return number(a) + (b)\n}\n```\n\nuse ESLint to check out code.\n```\nnpx lint src/sum.js\n\n/Users/easonzhan/learning/git_repos/jtils/src/sum.js\n  1:10  error  'foo' is defined but never used  no-unused-vars\n  2:10  error  Strings must use singlequote     quotes\n\n✖ 2 problems (2 errors, 0 warnings)\n  1 error and 0 warnings potentially fixable with the `--fix` option.\n```\nIf, you use VSCode or other editor you can install plugins for these editor to lint your code dynamically.\n\nI use vim, so I use a vim lint plugin ALE.\n\n6. Add Mocha to test your code.\n```\nyarn add --dev mocha\n```\ntest the code.\n```\n$  npx mocha\n~repos/jtils/test/sum.js:2\nimport sum from \"../src/sum\"\n       ^^^\n\nSyntaxError: Unexpected identifier\n    at new Script (vm.js:79:7)\n    at createScript (vm.js:251:10)\n    at Object.runInThisContext (vm.js:303:10)\n```\nThis error tells us we don't support ES6 Modules. So we need to add Babel to support.\n\n7. Add babel 7 support\n```\nyarn add --dev @babel/core @babel/cli @babel/preset-env\nyarn add --dev @babel/register\n```\nAnd for Babel 7, you should add a babel.config.js\n\n```\nmodule.exports = {\n  presets: [\"@babel/env\"]\n}\n```\n\nAnd then execute the Mocha.\n\n```bash\nnpx mocha --require @babel/register\n\n  Sum\n    Two Positives\n      ✓ should returns 4\n\n\n  1 passing (9ms)\n```\n\n8. About the `test/sum.js` code\n```javascript\nconst assert = require(\"assert\")\nimport sum from \"../src/sum\"\n\ndescribe(\"Sum\", function() {\n  describe(\"Two Positives\", function() {\n    it(\"should returns 4\", function() {\n      assert.equal(sum(2, 2), 4)\n    })\n  })\n})\n```\n#### Assertions\n\nIn the `test/sum.js` file, we use the Node.js built-in `assert` module to assert our code.\nMocha allows us to use any assertion libraries we wish. This means we can use libraries such as:\n- chai Chai is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework.\n- should.js   BDD style shown throughout these docs.\n- jest/expect\n- expect.js\n- better-assert\n- unexpected\n\nWe should use Chai, Because it has several interfaces that allow the developer to choose the most comfortable.\n\n#### Interfaces\n\nThe functions `describe(), it()` are Mocha's BDD \"interface\" system.\n\nMocha's \"interface\" system allows developers to choose thier style of DSL. Mocha has BDD, TDD, Exports, QUnit and Require-style interfaces.\n\n##### BDD\n\nThe BDD is shorted for Behavior Driven Development(BDD), So we can call Mocha is a BDD supprotable Testing Frameworks.\n\nThe BDD interface provides `describe(), context(), it(), specify(), before(), after(), beforeEach(), and afterEach().`\n\n`context() is just an alias for describe(), and behaves the same way; it just provides a way to keep tests easier to read and organized. Similarly, sepcify() is an alias for it().`\n\n```javascript\ndescribe('Array', function() {\n    before(function() {\n      // ...\n    });\n\n    describe('#indexOf()', function() {\n      context('when not present', function() {\n        it('should not throw an error', function() {\n          (function() {\n            [1,2,3].indexOf(4);\n          }).should.not.throw();\n        });\n        it('should return -1', function() {\n          [1,2,3].indexOf(4).should.equal(-1);\n        });\n      });\n      context('when present', function() {\n        it('should return the index where the element first appears in the array', function() {\n          [1,2,3].indexOf(3).should.equal(2);\n        });\n      });\n    });\n});\n```\n","readmeFilename":"readme.md","homepage":"https://github.com/AaronFlower/jtils#readme","repository":{"type":"git","url":"git+https://github.com/AaronFlower/jtils.git"},"author":{"name":"aaronflower"},"bugs":{"url":"https://github.com/AaronFlower/jtils/issues"}}