{"_id":"@brendonjohn/status-finder","_rev":"3-8e5e90bc0fe25af8d2c5c7362951e5e4","name":"@brendonjohn/status-finder","dist-tags":{"latest":"0.3.3"},"versions":{"0.3.1":{"name":"@brendonjohn/status-finder","version":"0.3.1","description":"Business logic tends to have many `if` statements and embedded `if` statements to decide what the current status is.","main":"dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","start":"tsc --watch","prepublish":"npm run build","postpublish":"git push origin master --tags","test":"ava --verbose"},"devDependencies":{"ava":"^2.4.0","ts-node":"^8.5.4","typescript":"^3.7.2"},"repository":{"type":"git","url":"git+https://github.com/brendonjohn/status-finder.git"},"author":{"name":"Brendon John Muschamp","email":"brendonmuschamp@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/brendonjohn/status-finder/issues"},"homepage":"https://github.com/brendonjohn/status-finder#readme","publishConfig":{"access":"public"},"ava":{"compileEnhancements":false,"extensions":["ts","tsx"],"require":["ts-node/register"],"files":["src/**/*test.ts","!dist"]},"gitHead":"d048ac346b5b49e9c87bb20581a727cf6fe05e2b","_id":"@brendonjohn/status-finder@0.3.1","_nodeVersion":"12.10.0","_npmVersion":"6.10.3","dist":{"integrity":"sha512-WGJ0vImSKtbHeXNB4UMakBNjJLpemR3ViRyXtfGIE6Y8xn8Y5v7ZQGvp2zPKTwaUtT+9qMDSTcoH5xjVkcVXRQ==","shasum":"371e34300c768a994cae58a68dd402efeef67a48","tarball":"https://registry.npmjs.org/@brendonjohn/status-finder/-/status-finder-0.3.1.tgz","fileCount":18,"unpackedSize":99630,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJd5ycKCRA9TVsSAnZWagAArmUQAIqfKg28SFVsIggz6bt5\nl4V4Z11bjdgyhQeyOjCMHDpk3xJKQHCLW/sJX0qVRKbWpoGDzlZsD7ZD+PkC\nduosTLXjtfT1o8tux4wYftwgCjHLsCdFlBKW+wfyUqWBFsZSZDdxMq3A6YDV\nRiiwXqMCaxcSMribX4W7+S6/OlswRHaPaA31ZySch+HY3fkxjm1IB4RSIEK7\nwioZy1SzdfeJvJCx7pvT1vPm0CwyvoJ+3ajmXCOkwQ0m+NvLLgKtvKlodi5j\nC7keyTGT3xk6f3SNYFl7C+Kt+0S0bjvxW9z25wWNPaV7vGghKLlPVKeXdwmy\n4jPgsqbXEb1B8c6ad4RGKmMsDB9pz3+NoHP4V2jv1ZVaSkogNTmChyIyWx4k\nz/07rJjPawT4tN3upLwXep/CQm4v7DQwj7iV4azSmQrTI+op7uxM5YmrtoG+\n6rTjx7kPP10w3HyM9DwfXAbwjSpLSb46/cQh8SjanOcrzhsEdIO5xNoTypPT\nhwTpV1S/iv7EhFicu4Ip6ym+ieNfD9li5UdU4cWvV1jU2+VV6ePPZdmolmGs\ny49qZtap3IATNS//n/LOoj1u3LsUEur/xw5WFWvjLf17EtOYkxw2Go44ujej\ntPCnY4EBjeIHKshbX/LfM0XEbYMnqKfXrLdjIMRN0fiSSD1Tta6FSZLTENiB\n6CxD\r\n=5dJ0\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDrPe7xe8viuLfH+LniHmLUDtn2H1kVlfdQL1uoWsEorwIgaE0x7iMdP260U3C9SExpw9PiBqFfiMZAWpQQvPvjp9o="}]},"maintainers":[{"name":"brendonjohn","email":"brendon@mish.guru"}],"_npmUser":{"name":"brendonjohn","email":"brendon@mish.guru"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/status-finder_0.3.1_1575429898132_0.17157801485979451"},"_hasShrinkwrap":false},"0.3.2":{"name":"@brendonjohn/status-finder","version":"0.3.2","description":"Business logic tends to have many `if` statements and embedded `if` statements to decide what the current status is.","main":"dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","start":"tsc --watch","prepublish":"npm run build","postpublish":"git push origin master --tags","test":"ava --verbose"},"devDependencies":{"ava":"^2.4.0","ts-node":"^8.5.4","typescript":"^3.7.2"},"repository":{"type":"git","url":"git+https://github.com/brendonjohn/status-finder.git"},"author":{"name":"Brendon John Muschamp","email":"brendonmuschamp@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/brendonjohn/status-finder/issues"},"homepage":"https://github.com/brendonjohn/status-finder#readme","publishConfig":{"access":"public"},"ava":{"compileEnhancements":false,"extensions":["ts","tsx"],"require":["ts-node/register"],"files":["src/**/*test.ts","!dist"]},"gitHead":"a13914ed14f6d8c3a91c3e306486c7e1a5638bfd","_id":"@brendonjohn/status-finder@0.3.2","_nodeVersion":"12.15.0","_npmVersion":"6.13.4","dist":{"integrity":"sha512-dm7aINUzEafpPQ8HC0eXt/iyi01fp+dzeYiRpDIrT/Ys/fXnSp4WtXS7Yd71xkUc9c76Cla0ViOK/bXWaEdrtw==","shasum":"380e66e7c4756434940b24cfac9a584768572261","tarball":"https://registry.npmjs.org/@brendonjohn/status-finder/-/status-finder-0.3.2.tgz","fileCount":18,"unpackedSize":99631,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJeYzoWCRA9TVsSAnZWagAAJbUP/3aok0MZfs/DZiryQ65j\nqU4KbGkzLOV4XW6A4+HSRmg3Ms4IT8l/PpLessqhoVKPy448Slj17YAlsWM5\nboG+qgXIpHLx6VPDmFnStOtZJlU8NjmeEmHDW7QWxIeEYNBHCTJcLFiv0/g2\nNRH/XRiU78rMXDkNfKOqIF9z0PFKcJzXVhnEwhXt3hjHMnSnWH4zvmv9QySi\nCbUTh09UQ6O1HF+omlXbMr4L0cLTnyssRvrXuQspHk+sVH+pql4YlwV3oSUd\n+RAFLfXxsjeeBIB8oL05cWHaPzswiZgJFZX9JC6EKYLZB3DQuS6YknPPgxui\n2hrYEzY27VzRGlr+RFACDx+Jv5+RZUy3t9v77sYDOJ4P4Ot46V0/Ka6txrKn\n4TKqGYRXdNUNBHB8q0sOJzZzhqlFX+GiiM4sFmHB5tExStgwC08Gn33QsQad\nlnfm3LxXKtTYbTzf0LZM6w8Fky4DxGRzBRCw8atlIDv7BaPOC92nsKgZ0qlu\n7yELqO7wUwCsXOxLhogxQeMuL8Y+S7P9G7w+uK/jSj7gcYXz+hBtiWvny1W8\nz/GCoEdVxpVSsk8mUkhi4J7uaiio3owtPva2k7E/F/iNCz+SHxrABYvQSxAW\n4L6QYzye3clBmZUBzf3X7zwKgLoM1d7GwlLBKyyRQ5mO0xMk265iTQcjMhfk\nCWIN\r\n=LcYF\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBNDwRNP9Kue7qMcVTxCDeOeudsxruqFeN/H+qV8G8WUAiBjFmYE6DuhsjUAVucAgDXVuViEIl2aQn1loW4Cw4UJ0g=="}]},"maintainers":[{"name":"brendonjohn","email":"brendon@mish.guru"}],"_npmUser":{"name":"brendonjohn","email":"brendonmuschamp@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/status-finder_0.3.2_1583561238109_0.9463963458591405"},"_hasShrinkwrap":false},"0.3.3":{"name":"@brendonjohn/status-finder","version":"0.3.3","description":"Business logic tends to have many `if` statements and embedded `if` statements to decide what the current status is.","main":"dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsc","start":"tsc --watch","prepublish":"npm run build","postpublish":"git push origin master --tags","test":"ava --verbose"},"devDependencies":{"ava":"^3.8.2","ts-node":"^8.10.1","typescript":"^3.9.3"},"repository":{"type":"git","url":"git+https://github.com/brendonjohn/status-finder.git"},"author":{"name":"Brendon John Muschamp","email":"brendonmuschamp@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/brendonjohn/status-finder/issues"},"homepage":"https://github.com/brendonjohn/status-finder#readme","publishConfig":{"access":"public"},"ava":{"extensions":["ts","tsx"],"require":["ts-node/register"],"files":["src/**/*test.ts","!dist"]},"gitHead":"51ea604ed7a20f1bc4ae5e923069eeceba2e0b7d","_id":"@brendonjohn/status-finder@0.3.3","_nodeVersion":"14.0.0","_npmVersion":"6.14.4","dist":{"integrity":"sha512-+Tu88yRtQvXvDVuTsEG7VYFR6MTyEyRWLPpTPAD/GGmWXPug4KpSLLc380P3bSdlMJpwW6Otcqk0dDTIiGJ1Tw==","shasum":"d9d0c04f5ce2e853196e6bc2451eee2da90f21e2","tarball":"https://registry.npmjs.org/@brendonjohn/status-finder/-/status-finder-0.3.3.tgz","fileCount":18,"unpackedSize":110024,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJexxXgCRA9TVsSAnZWagAAYg8P/2k+OHZPtGuz3EmwbPBM\nYDyW0GDdk62QAMAJQKjDPnNTK3kBjF1lrVvs0e5IxUt6ejqMZJwME6r6i9K2\nXaMNcib1G5UC8dgJn47oH6ZRjfcQk8KwPSYQrURdJUf4iP/X+9j813MbKoca\n9Ni3rrkMQCNs/aXI1X3bf9R5lcXcNfL0IEF0VaS3LgIxSWyKZSMX65GNB4FU\nNTTYuyNh2G0KUfCp2ptxO099Q6Ha0lSie0jVcVXf99c7ymzP1qv89fX2BH1B\n5qfmaWbbljGAknsuKWV923jCoG8uXMEIoUv9aQIe0e5PhMg3o+d+BqKzOSJq\n6bsGIZ6kyyALHXci5YobX/RW3Vz4+MLDnbCST2bkFF/DkVg1PGIZ5wJxEZl2\njpSkHVg5ZtMoGZZZ72iqypdBN9NpUoOtgC/tbGN9WvUPrvz8G1/2FJmOFc8/\nymlFkHielB0zZTR+XEQkg2QpfX0J+yulBdyF8uWT1leknruNJ7wyln270ied\n2a6XjfxLAOTv7JzkOyPa3SIBkzytfkD0j5VLR3C87+tk3lo56YfMLstqACst\nywPRPoIuGKZq5G0oH31nN+m3PEk1M4UfHZsRrgMIesyQqpO1GP/TP8ATbFgj\nUcm2m/sjCDXrfqN06OLwlQ08CeQ9WfRUdJ+GMEJknwRUxiOkkDMOdl0ri95Z\nT6UV\r\n=+Uo4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCID7OvyxiZpcrCnwlfnQKpPUMWGnByngWIKrAEVUOvZgwAiByZZ9hr1EPfsNOpSBWWI86JEmFK7tTd2Q6odlZPRJDjg=="}]},"maintainers":[{"name":"brendonjohn","email":"brendon@mish.guru"}],"_npmUser":{"name":"brendonjohn","email":"brendonmuschamp@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/status-finder_0.3.3_1590105568195_0.6657278980555363"},"_hasShrinkwrap":false}},"time":{"created":"2019-12-04T03:24:58.088Z","0.3.1":"2019-12-04T03:24:58.343Z","modified":"2022-04-04T20:31:21.233Z","0.3.2":"2020-03-07T06:07:18.236Z","0.3.3":"2020-05-21T23:59:28.364Z"},"maintainers":[{"name":"brendonjohn","email":"brendon@mish.guru"}],"description":"Business logic tends to have many `if` statements and embedded `if` statements to decide what the current status is.","homepage":"https://github.com/brendonjohn/status-finder#readme","repository":{"type":"git","url":"git+https://github.com/brendonjohn/status-finder.git"},"author":{"name":"Brendon John Muschamp","email":"brendonmuschamp@gmail.com"},"bugs":{"url":"https://github.com/brendonjohn/status-finder/issues"},"license":"ISC","readme":"# @brendonjohn/status-finder #\n\nBusiness logic tends to have many `if` statements and embedded `if` statements to decide what the current status is.\n\nThis tool is an alternative for writing and reviewing business logic that needs to decide what status we are currently in.\n\nI thought I was making a finite state machine… but that’s really something else. This is instead a little tool to simplify how a status of many paths can be derived from state.\n\n## Install\n\n```\nnpm install @brendonjohn/status-finder\n```\n\n## Goals\n\n- Represent possible states as data instead\n- Make domain knowledge easier to review, test and typecheck\n- Encourage all related state to be found before deriving what the current status is\n- Encourage a clear distinction between retrieving data and deriving information from the data\n\n## Concepts\n\n### Status Tree\n\nThis is a data structure that represents the a hierarchy of logic to make sense of the state.\n\nThe Status Tree is made up of `Status Node`s and `subStates`. Each node contains a test function to decide if this is the current status.\n\nEach node in the StatusTree can have an array of sub states that also need to be checked.\n\n#### Status Node ####\n\nOne of the possible outcomes from evaluating a Status Tree\n\n##### Status #####\n\nThe value of the `status` property on a `Status Node`. This value will be returned by the statusFinder\n\n##### Test #####\n\nThe value of the `test` property on a `Status Node`.\n\nThis value is a function that will be proided the application `state` as an argument and returns a `boolean`.\n\nThis function has to decide whether the current Status Node is a match or not.\n\n#### Sub Status Nodes ####\n\nEach `Status Node` can specify `Sub Status Nodes` in the `subStates` property.\n\nIn the same way we like to write nested `if` statements, subStates exist to reduce code duplication.\n\nEach status node has the option to specify subStates. Each subState implements the same shape as the `Status Node`.\n\n### State\n\nA value that each `Status Node` will be tested against. The state should be designed by you and can be as simple or complex as your application requires.\n\n### Status Finder ###\n\n1. A recursive method that determines which `status` in the `StatusTree` matches the provided state. We start at the first position of the array (arrays start at zero) and evaluate one node at a time.\n\n2. When a status match is found, we store the value of the current match and check if there are sub states we need to test against.\n\n3. We repeat point 2 on the sub states until we have run out of sub states to check.\n\n4. When we have run out of sub states to check, we return the value of the latest match\n\n5. When we have found a node that matches, the value of the `status` property of that node will be returned.\n\n## Example\n\nI've put together an example that shows sub states being used. See [src/example.ts](src/example.ts)\n\n## Author\n\n[Brendon Muschamp](http://github.com/brendonjohn)\n\n\n## License\n\nCopyright 2019 @brendonjohn\n\nPermission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n","readmeFilename":"README.md"}