{"_id":"nothing-mock","_rev":"8-aae58eaa81ccc894b734feda80acfc21","name":"nothing-mock","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"nothing-mock","version":"1.0.0","keywords":["nothing","chainable","callable","mock","testing"],"author":{"name":"Vladimir Simonov","email":"slmgc@ya.ru"},"license":"MIT","_id":"nothing-mock@1.0.0","maintainers":[{"name":"slmgc","email":"slmgc@ya.ru"}],"homepage":"https://github.com/slmgc/Nothing","bugs":{"url":"https://github.com/slmgc/Nothing/issues"},"dist":{"shasum":"971a93de60aa938418971153b6fc79b34427ad69","tarball":"https://registry.npmjs.org/nothing-mock/-/nothing-mock-1.0.0.tgz","fileCount":10,"integrity":"sha512-IzL50y51eh10O4GQ1DTidPDdIoJCrpSMAvzb4oAcZPLo/w0vKzV0OlN2JDfz1HKz7illU1uDM7b8TyoUOPD0RA==","signatures":[{"sig":"MEUCIB4szSV9lpH/KyNVj1ewV5/z/SF8X8lfyNCs1BpqzRMmAiEAsIl3PrXqma+hjMOIxt8lk2mBluFMBH9UlwgpXIiI2Ec=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":12529},"main":"dist/nothing-mock.js","module":"dist/nothing-mock.es.js","gitHead":"8f690d86d98e5bc27bccf245dad2c833b3c36757","scripts":{"build":"microbundle --strict"},"_npmUser":{"name":"slmgc","email":"slmgc@ya.ru"},"repository":{"url":"git+https://github.com/slmgc/Nothing.git","type":"git"},"_npmVersion":"5.6.0","description":"A chainable, callable mock object which always returns itself","directories":{},"jsnext:main":"dist/nothing-mock.es.js","_nodeVersion":"9.9.0","_hasShrinkwrap":false,"devDependencies":{"microbundle":"^0.4.4"},"_npmOperationalInternal":{"tmp":"tmp/nothing-mock_1.0.0_1522513977544_0.22212737833429652","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"nothing-mock","version":"1.0.1","keywords":["nothing","chainable","callable","mock","testing"],"author":{"name":"Vladimir Simonov","email":"slmgc@ya.ru"},"license":"MIT","_id":"nothing-mock@1.0.1","maintainers":[{"name":"slmgc","email":"slmgc@ya.ru"}],"homepage":"https://github.com/slmgc/Nothing","bugs":{"url":"https://github.com/slmgc/Nothing/issues"},"dist":{"shasum":"3c5baa1f47abe8ddbc6c167699520f95626c334a","tarball":"https://registry.npmjs.org/nothing-mock/-/nothing-mock-1.0.1.tgz","fileCount":11,"integrity":"sha512-88Qc9NnZPK/tK/wHXC8Q8fFhtibRKXJUR0mAE2YSDrYxLVE6EqEMfCknzWXtA3gGx2YLAERUOIGPIx+8goApjA==","signatures":[{"sig":"MEUCIBOzckJ9c6Qfwfz1Wyn62AP4uZf4Zi4m6Odf05VJy+gxAiEAg2x39xNLq5whHW1RM2BQwTOw4Awfp51dwQoHJImBHHo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":16944},"main":"dist/nothing-mock.js","module":"dist/nothing-mock.es.js","gitHead":"6054faa312dd74d223a86854f0404e7e86ff965c","scripts":{"build":"microbundle --strict"},"_npmUser":{"name":"slmgc","email":"slmgc@ya.ru"},"repository":{"url":"git+https://github.com/slmgc/Nothing.git","type":"git"},"_npmVersion":"5.6.0","description":"A chainable, callable mock object which always returns itself","directories":{},"jsnext:main":"dist/nothing-mock.es.js","_nodeVersion":"9.9.0","_hasShrinkwrap":false,"devDependencies":{"microbundle":"^0.4.4"},"_npmOperationalInternal":{"tmp":"tmp/nothing-mock_1.0.1_1523100609930_0.6345510392924332","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"nothing-mock","version":"1.0.2","keywords":["nothing","chainable","callable","mock","testing"],"author":{"name":"Vladimir Simonov","email":"slmgc@ya.ru"},"license":"MIT","_id":"nothing-mock@1.0.2","maintainers":[{"name":"slmgc","email":"slmgc@ya.ru"}],"homepage":"https://github.com/slmgc/Nothing","bugs":{"url":"https://github.com/slmgc/Nothing/issues"},"dist":{"shasum":"e269ce26919e9b13c7ad0178348ab2b060186879","tarball":"https://registry.npmjs.org/nothing-mock/-/nothing-mock-1.0.2.tgz","fileCount":11,"integrity":"sha512-7/Ss8rzSY78UX0cbPB8Qj7X6IHV+QO7T0Rq2nYbpd7HymBCE0HIWSjoTjqbSVV8JSuuD50oVObwZDfvnwOT/NQ==","signatures":[{"sig":"MEUCIQD2MoBwXRVfxmo+qbGVbm7+05UWWM2fhVbmXlDzBZ191wIgRaQNY+xBwRjKOMXfFAyCvXMUBkgcfg5mhDJ9TmiNJgk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":15983},"main":"dist/nothing-mock.js","module":"dist/nothing-mock.es.js","gitHead":"1cc0d0284b77bb0f5a249a57227b3a0fb4aeb2cf","scripts":{"build":"microbundle --strict"},"_npmUser":{"name":"slmgc","email":"slmgc@ya.ru"},"repository":{"url":"git+https://github.com/slmgc/Nothing.git","type":"git"},"_npmVersion":"5.6.0","description":"A chainable, callable mock object which always returns itself","directories":{},"jsnext:main":"dist/nothing-mock.es.js","_nodeVersion":"9.9.0","_hasShrinkwrap":false,"devDependencies":{"microbundle":"^0.4.4"},"_npmOperationalInternal":{"tmp":"tmp/nothing-mock_1.0.2_1523244639159_0.11383593507774226","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"nothing-mock","version":"1.0.3","keywords":["nothing","chainable","callable","mock","testing"],"author":{"name":"Vladimir Simonov","email":"slmgc@ya.ru"},"license":"MIT","_id":"nothing-mock@1.0.3","maintainers":[{"name":"slmgc","email":"slmgc@ya.ru"}],"homepage":"https://github.com/slmgc/Nothing","bugs":{"url":"https://github.com/slmgc/Nothing/issues"},"dist":{"shasum":"0cb5fd6869e10773804af57cdbcf2a139b5e68d0","tarball":"https://registry.npmjs.org/nothing-mock/-/nothing-mock-1.0.3.tgz","fileCount":13,"integrity":"sha512-oKf+W3osgBSbgHpBvaAOz8E6XYcBoTTbBD6jPInU/qqkwwd/GY2akika0EyUnnx/hIWbez65+hiBxVJjyDZMKw==","signatures":[{"sig":"MEYCIQCn+mfn+N8YlRw9QoYb1Fjnt2CabI+0OkQZyKtytGbybwIhAO1wzMK0TlagjRpPSyFVrqdMNMSVGhUvHlJpDYaHGKad","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18201,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgZXMuCRA9TVsSAnZWagAALFoP/1fRhSUmruw04TCW645k\nz9U7JgU0ikpmk1E0p9qmdh3RIU/MNlU+Bu2RWQoZknuc5cNaiydAHIIviznK\ninjIYyzylWS1AmFUNaY50ZsjDCMJYACGobHyqgG9gGaIFpENH6CIebIZ/tQE\nItRH4U50qojtSXOkSZLnGp3rLen5JkZCB0s72GmdCn1iapVf9rOyHl3gg5O4\nCkYgbkgJwAG+/0G80mq9IU53veq4GrG9pOu3zLc64OgpizFoEE79um7cPWZs\njbFbXaLsdQXMMwEkR40M0+Xud7E3L2L3idIPwfy9CaM6IipHGUx/jVRqbn/k\nxj3F/byTxCfoKqyYuCNFp2SV4zpVq7SbKfxJyoYAyQjLUv4bSNCWCEp6uywX\nQtjK/hQX4/dJLuAhPbheRV43wRZAk8xVU5FaC/G3C6Gd6lm79Fz4u3QL+bCH\nQM82ldi1BrPV60cURzliXsUDXerFoWapeNfykBG1jnl1ZShy8low7j0HKic9\nNkX4Isha0Xii8b7mNxH1eNRjOA+g/A6sSpViTF+v/0QL2SjfONhep4lSIm20\ny0i4hoA77WxactMotZ1SL5t8P65yM7763ssfIfG3OUJmNGk82eIbg2C8RR4z\nGnuaTXg7t5H6hNRvQm10T9lQpKox6vnSEAt3Rip0cwAw9LlFd4Fms5gvNWV4\nnfb8\r\n=VdYV\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/nothing-mock.js","types":"index.d.ts","unpkg":"dist/nothing-mock.umd.js","module":"dist/nothing-mock.es.js","source":"src/index.js","exports":"dist/nothing-mock.modern.js","gitHead":"e8e934331259e5c9b4e0f2570bfba82b77761b47","scripts":{"build":"microbundle --strict"},"_npmUser":{"name":"slmgc","email":"slmgc@ya.ru"},"repository":{"url":"git+https://github.com/slmgc/Nothing.git","type":"git"},"_npmVersion":"7.7.6","description":"A chainable, callable mock object which always returns itself","directories":{},"jsnext:main":"dist/nothing-mock.es.js","_nodeVersion":"14.15.5","_hasShrinkwrap":false,"devDependencies":{"microbundle":"^0.13.0"},"_npmOperationalInternal":{"tmp":"tmp/nothing-mock_1.0.3_1617261358518_0.7583611145505569","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"nothing-mock","version":"1.0.4","keywords":["nothing","chainable","callable","mock","testing"],"author":{"name":"Vladimir Simonov","email":"slmgc@ya.ru"},"license":"MIT","_id":"nothing-mock@1.0.4","maintainers":[{"name":"slmgc","email":"slmgc@ya.ru"}],"homepage":"https://github.com/slmgc/Nothing","bugs":{"url":"https://github.com/slmgc/Nothing/issues"},"dist":{"shasum":"470b6bd7f7e0dd900b101ed77178683db5141298","tarball":"https://registry.npmjs.org/nothing-mock/-/nothing-mock-1.0.4.tgz","fileCount":13,"integrity":"sha512-wl5hpQruSQHt5M15oY/akWd7hFPyec0uTCUHYQa3WhBeTxonsFnMKmixaCDvb4U7MN9UjS2UvXw3s4KxjrNjKg==","signatures":[{"sig":"MEUCIQDO+A4xAmiJ2lQYyocGXwVrtGApI1RS0V8mu54UlOkgQwIgblprXtZCSYFgnInK8XuBUTSrTFWtnGPe+CMyWVrQC1o=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":18202,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJga0OoCRA9TVsSAnZWagAAHHoP/0BuI+j0pjrJLRoutkU0\nx9SH9hICXxH7vL7wix/mhttHt6nkqP0NqGwWweJObCHS3j/YnZCp7bZ0ajuO\n0c7kMmTl5PRcxHs6VSSN1+pBR29vN3ae8HicPwZJjM/5HaqwLiIlS4bHsO4L\nHVegB1T00nrvlEXuGzYNywwg/TXBvLqS1ptsA8FETDXI9zbIMfjiO0QVS5Zm\nkOCXaQSFcyqut1sTAiMvg53v/gCvCzI0FxBiC8L06/Wg/qTKuzrSblyJPIGV\nVidywReW0DUVC8jKhT+WscjVZyPgZGWbfGQZNsKSa5RWYgWrQhJlP4poirXN\n21RjV2r3fztvZ7O2LE6Kc4pRzIvr+4siK5KmSmGABadkts7Q/Njd7ZlD51Nj\nQhVhpJVfJJtZg///i3K27k4Y1vm7xbh8k4aujMFIRZi9bSUkTZa9KaGQVcJF\nwXrsTCrmoh6aRTcRZx4uu+JpAojx57D2zBnqkDylIf2QuF6yRKkUp0kwc8xt\njNDDFDEg6yshgcC1W8Tp8oHADvBcpX89Il8TIrUNHsQpaq7SIrZxxNWBdoDr\nDiWcn9SIXqeH85EsYG5QnCZMuxXEIMnbO7cPl+B62hd9D1zwQ8YsXrAGKIrG\nENOj0MTYq0U+DbBl/dpTCan4J0AwJSoHD0YCRoLW1umtYjEdjSZwA8upoAXZ\nf2oP\r\n=51Md\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/nothing-mock.js","types":"index.d.ts","unpkg":"dist/nothing-mock.umd.js","module":"dist/nothing-mock.es.js","source":"src/index.js","gitHead":"fd8441054b11fc6e245fe0e023aae4956ea07956","scripts":{"build":"microbundle --strict"},"_npmUser":{"name":"slmgc","email":"slmgc@ya.ru"},"esmodule":"dist/nothing-mock.modern.js","repository":{"url":"git+https://github.com/slmgc/Nothing.git","type":"git"},"_npmVersion":"7.7.6","description":"A chainable, callable mock object which always returns itself","directories":{},"jsnext:main":"dist/nothing-mock.es.js","_nodeVersion":"15.13.0","_hasShrinkwrap":false,"devDependencies":{"microbundle":"^0.13.0"},"_npmOperationalInternal":{"tmp":"tmp/nothing-mock_1.0.4_1617642408388_0.20107841491187206","host":"s3://npm-registry-packages"}},"1.0.5":{"name":"nothing-mock","version":"1.0.5","license":"MIT","description":"A chainable, callable mock object which always returns itself","author":{"name":"Vladimir Simonov","email":"slmgc@ya.ru"},"homepage":"https://github.com/slmgc/Nothing","repository":{"type":"git","url":"git+https://github.com/slmgc/Nothing.git"},"main":"dist/nothing-mock.js","module":"dist/nothing-mock.es.js","esmodule":"dist/nothing-mock.modern.js","jsnext:main":"dist/nothing-mock.es.js","unpkg":"dist/nothing-mock.umd.js","source":"src/index.js","types":"index.d.ts","scripts":{"build":"microbundle --strict"},"devDependencies":{"microbundle":"^0.15.1"},"keywords":["nothing","chainable","callable","mock","testing"],"gitHead":"844eacd2e114953a23c7e546bbb26171ec9b8065","_id":"nothing-mock@1.0.5","bugs":{"url":"https://github.com/slmgc/Nothing/issues"},"_nodeVersion":"26.3.0","_npmVersion":"11.16.0","dist":{"integrity":"sha512-8eR2BxbeKJd5rF4gt/ec9juomGqI/phYYEsWF0SSM6cBBpnAHrxhiBON6SLLd++CRzfY8ceSnApc2mRUaiI5ng==","shasum":"2cc9a827c8abdd40a3d465bea009b3e09952193f","tarball":"https://registry.npmjs.org/nothing-mock/-/nothing-mock-1.0.5.tgz","fileCount":13,"unpackedSize":18529,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBjhv25ywJIHP48QBq4qLLx8ay2rzV+fzeFfu0mqE73PAiEAq6OzX05QhSxzPXrCHrE4MksLTSkiOmKGFfnQPDmGUIg="}]},"_npmUser":{"name":"slmgc","email":"slmgc@ya.ru"},"directories":{},"maintainers":[{"name":"slmgc","email":"slmgc@ya.ru"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/nothing-mock_1.0.5_1781443415387_0.013229246122020477"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-31T16:32:57.543Z","modified":"2026-06-14T13:23:35.633Z","1.0.0":"2018-03-31T16:32:57.602Z","1.0.1":"2018-04-07T11:30:10.008Z","1.0.2":"2018-04-09T03:30:39.255Z","1.0.3":"2021-04-01T07:15:58.652Z","1.0.4":"2021-04-05T17:06:48.500Z","1.0.5":"2026-06-14T13:23:35.527Z"},"bugs":{"url":"https://github.com/slmgc/Nothing/issues"},"author":{"name":"Vladimir Simonov","email":"slmgc@ya.ru"},"license":"MIT","homepage":"https://github.com/slmgc/Nothing","keywords":["nothing","chainable","callable","mock","testing"],"repository":{"type":"git","url":"git+https://github.com/slmgc/Nothing.git"},"description":"A chainable, callable mock object which always returns itself","maintainers":[{"name":"slmgc","email":"slmgc@ya.ru"}],"readme":"# Nothing\n\n[![npm package][npm-badge]][npm] [![npm package][npm-downloads]][npm]\n\n**Nothing** is a chainable, callable mock object which always returns itself. You can use it instead of `null` and `undefined` values so you don't have to place safety checks all over your code. The implementation uses [Symbol] and [Proxy] behind the hood which are widely supported by modern desktop and mobile browsers and can be used without a polyfill.\n\n## How to install\n\n```\nnpm i -S nothing-mock\n```\n\n## How to use\n\n### A simple example\n```js\nimport {Nothing} from 'nothing-mock'\n\nconst foo = Nothing\nfoo.bar.baz.qux().spam.ham[0].map((x) => x + 1).eggs.someFn() // returns Nothing\n```\n\n### Reducing boilerplate\n```js\nimport {Nothing} from 'nothing-mock'\n\n// A regular function with null-checks\nfunction someFunctionWithNullChecks(foo) {\n\treturn foo &&\n\t\tfoo.bar &&\n\t\tfoo.bar.baz &&\n\t\tfoo.bar.baz.qux &&\n\t\tfoo.bar.baz.qux()\n}\n\n// There is no need to check for null/undefined if you use Nothing\nfunction someFunction(foo) {\n\treturn foo.bar.baz.qux()\n}\n\nsomeFunctionWithNullChecks(null) // returns null\nsomeFunction(Nothing) // returns Nothing\nsomeFunction(null) // throws an exception\n```\n\n### JSON serialization/deserialization\n```js\nimport {Nothing, deserialize, serialize} from 'nothing-mock'\n\nconst json = `{\n\t\"posts\": [{\n\t\t\"id\": 1,\n\t\t\"userId\": 12,\n\t\t\"content\": \"post 1\",\n\t\t\"comments\": [{\n\t\t\t\"id\": 1,\n\t\t\t\"userId\": 34,\n\t\t\t\"content\": \"comment 1\"\n\t\t}, {\n\t\t\t\"id\": 2,\n\t\t\t\"userId\": 56,\n\t\t\t\"content\": \"comment 2\"\n\t\t}]\n\t}, {\n\t\t\"id\": 2,\n\t\t\"userId\": 78,\n\t\t\"content\": \"post 2\",\n\t\t\"comments\": null\n\t}]\n}`\n\nconst {posts} = deserialize(json) /* returns: [{\n\t\"id\": 1,\n\t\"userId\": 12,\n\t\"content\": \"post 1\",\n\t\"comments\": [{\n\t\t\"id\": 1,\n\t\t\"userId\": 34,\n\t\t\"content\": \"comment 1\"\n\t}, {\n\t\t\"id\": 2,\n\t\t\"userId\": 56,\n\t\t\"content\": \"comment 2\"\n\t}]\n}, {\n\t\"id\": 2,\n\t\"userId\": 78,\n\t\"content\": \"post 2\",\n\t\"comments\": Nothing // null values are replaced with Nothing\n}] */\n\nfunction renderPostWithComments(post) {\n\treturn `<div>\n\t\t<p>${post.content}</p>\n\t\t<ul>${post.comments.map((comment) =>\n\t\t\t`<li>${comment.content}</li>`).join('')\n\t\t}</ul>\n\t</div>`\n}\n\nposts.map(renderPostWithComments).join('') /* returns:\n`<div>\n\t<p>post 1</p>\n\t<ul>\n\t\t<li>comment 1</li>\n\t\t<li>comment 2</li>\n\t</ul>\n</div>\n<div>\n\t<p>post 2</p>\n\t<ul></ul> // Nothing is rendered empty\n</div>` */\n\n// Serializes an object to JSON and\n// replaces all Nothing values with null\nserialize({posts})\n```\n\n### Helper functions\n```js\nimport {Nothing, toBool, isNothing, isSomething} from 'nothing-mock'\n\nconst list = [Nothing, true, false, null, undefined, 0, 1, NaN, '', {}, []]\nlist.filter(toBool) // [true, 1, {}, []]\nlist.filter(isNothing) // [Nothing]\nlist.filter(isSomething) // [true, false, 0, 1, NaN, \"\", {}, []]\n```\n\n### Properties which don't return Nothing\n```jsx\nimport {Nothing} from 'nothing-mock'\n\nNothing.length // 0\nNothing.name // a string\nNothing.prototype // an object with a constructor\nNothing.toLocaleString() // \"\"\nNothing.toString() // \"\"\nNothing.valueOf() // false\n```\n\n### Gotchas\n```js\nimport {Nothing, toBool} from 'nothing-mock'\n\nString(Nothing) // \"\"\nNothing.toString() // \"\"\nNothing + 'a string' // \"a string\"\nNothing * 123 // 0\nNothing - 123 // -123\n\n// Gotcha: concatenation of Nothing and a number returns a string\nNothing + 123 // \"123\"\n\n// Solution: Nothing can be excplicitly converted to a number\nNumber(Nothing) // 0\nNumber(Nothing) + 123 // 123\n\n// Gotcha: typecasting of Nothing to a boolean returns true\nBoolean(Nothing) // true\n!!Nothing // true\n\n// Solution: Nothing can be converted to false\nNothing.valueOf() // false\ntoBool(Nothing) // false\n\n// Gotcha: returning Nothing from a promise never\n// resolves as Nothing is a thenable object\nsomePromise\n\t.then(() => Nothing)\n\t.then((result) => result) // pending indefinitely\n\n// Solution: wrapping Nothing resolves the issue\nsomePromise\n\t.then(() => ({result: Nothing}))\n\t.then((result) => result) // promise resolves\n```\n\n## FAQ\n\nQ-1: Proxies are slow and there is a runtime overhead. Why should I use **Nothing**?\n\nA: You should keep a few things in mind:\n\n1. \"Premature optimization is the root of all evil\" - Donald E. Knuth.\n2. Have you checked the performance of **Nothing**? Does it really impact the performance of your code? If it does, you can always opt out using **Nothing** for performance-critical parts of your code.\n3. You can use **Nothing** for writing unit tests which are less likely to be performance-dependant.\n\nQ-2: I believe that it's hard to understand the logic as the code will fail silently if I would use **Nothing**. I prefer to use try/catch blocks instead, e.g.:\n\n```js\ntry {\n\tfoo.bar.baz()\n} catch (e) {\n\t// deal with it somehow\n}\n```\n\nA: Many functional programming languages either don't have or don't endorse the use of imperative constructs such as try/catch blocks because they introduce so-called side effects which actually make it harder to debug and reason about the code. And programs which are written in functional programming languages are considered to be less error-prone and easier to support.\n\nYou can always check the result if a function call should never return **Nothing** and then handle it properly:\n\n```js\nconst someFunction = (handleNothing, arg) => {\n\tconst result = foo.bar.baz(arg)\n\treturn isNothing(result) ? handleNothing(arg) : result\n}\n```\n\nQ-3: Why should I use **Nothing** if there are better alternatives like [optional chaining] or [lodash.get]?\n\nA: Each of these solutions have their pros and cons. Your choice should depend on the use-case:\n\n1. Optional chaining syntax would be the best choice, but it requires a transpilation step as modern browsers don't support the syntax and it might take a while before it will get into the future ECMAScript standard.\n2. `lodash.get` is good for a basic property chain traversal, but it requires an alien syntax and fails when there is a need to call a method somewhere in a property chain:\n\n```js\nimport get from 'lodash.get'\n\nvar foo = null\nget(foo, ['bar', 'baz'])() // this will throw an exception\n\nvar baz = get(foo, ['bar', 'baz'])\nbaz && baz() // this won't work if `baz` should be bound to the context of `bar`\n\n// For example:\nvar foo = {\n\tbar: {\n\t\tbaz() {\n\t\t\tconsole.log(this.qux)\n\t\t},\n\t\tqux: 'hello'\n\t}\n}\n\nfoo.bar.baz() // \"hello\"\nget(foo, ['bar', 'baz'])() // undefined\n\n// This would be a proper solution:\nvar bar = get(foo, ['bar'])\nvar baz = get(bar, ['baz'])\nbaz && baz.call(bar) // \"hello\"\n\n// But then it's easier to get back to the regular syntax:\nfoo && foo.bar && foo.bar.baz && foo.bar.baz()\n\n// And good luck using `get` for something like this:\nfoo.bar.baz()[0].map(() => { /* do something */ })\n\n// BTW, an implementation of a lodash-like `get` helper-function is basically a one-liner:\nconst get = (o, a) => a.reduce((p, c) => p && p[c], o)\n```\n\nQ-4: I am still not convinced and ain't gonna use **Nothing**!\n\nA: Thanks for letting me know! Seriously, it's your choice, I am down with it.\n\n## License\n**MIT**\n\n[Proxy]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy#Browser_compatibility\n[Symbol]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol#Browser_compatibility\n[npm]: https://www.npmjs.org/package/nothing-mock\n[npm-badge]: https://img.shields.io/npm/v/nothing-mock.svg\n[npm-downloads]: https://img.shields.io/npm/dm/nothing-mock.svg\n[optional chaining]: https://www.npmjs.com/package/babel-plugin-transform-optional-chaining\n[lodash.get]: https://www.npmjs.com/package/lodash.get\n","readmeFilename":"README.md"}