{"_id":"@bothy/trucks","_rev":"4-06960b8f214faf0483fbba5a6d7662a4","name":"@bothy/trucks","dist-tags":{"latest":"4.0.0"},"versions":{"1.0.0":{"name":"@bothy/trucks","version":"1.0.0","license":"ISC","_id":"@bothy/trucks@1.0.0","maintainers":[{"name":"bgraceful","email":"graceful.bryonics@proton.me"}],"dist":{"shasum":"fc61463c7abd5cda1a59787aac0fb7bf2a1f3201","tarball":"https://registry.npmjs.org/@bothy/trucks/-/trucks-1.0.0.tgz","fileCount":13,"integrity":"sha512-CF8Lh/7kIJ2sQJK38Jeb1oue/YuO0AToxbbNLeIKD6wV22n4pSB88ISpffLIR4rXxRhQ/lwMIBSEY8ECr87zvA==","signatures":[{"sig":"MEQCIGukF9tBYTnsjf078BpHNGmSFkh1xpza7IG+9xyS1M4GAiBgNLXdQMJCLKVdAXD0G3zSs+llzxGvZc6avigD7NuLkg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21851},"type":"module","gitHead":"72a7adcc13c4c35facd710ac7435d6cb58579ffb","scripts":{"status":"vitest run","publication-1":"npm publish --access public","status-monitor":"vitest"},"_npmUser":{"name":"bgraceful","email":"graceful.bryonics@proton.me"},"_npmVersion":"9.2.0","description":"``` State Management is: * An object singleton that is monitored for changes \t* Methods for checking if a particular change occurred to that object ```","directories":{},"_nodeVersion":"18.19.0","dependencies":{"lodash":"^4.17.21"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.0.3","jsdom":"^25.0.1","vitest":"^0.34.4"},"_npmOperationalInternal":{"tmp":"tmp/trucks_1.0.0_1740183714635_0.8122766421482246","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"@bothy/trucks","version":"2.0.0","license":"ISC","_id":"@bothy/trucks@2.0.0","maintainers":[{"name":"bgraceful","email":"graceful.bryonics@proton.me"}],"dist":{"shasum":"de40e657c053063be3f0ac258409d975dd5f9406","tarball":"https://registry.npmjs.org/@bothy/trucks/-/trucks-2.0.0.tgz","fileCount":13,"integrity":"sha512-xtPLExsOWC5i6qPDiZbiwZT6z41yZSedjm84ewkTLAnU7mGpscMqtUOga24Hfk8jQJjiDPwyiNGT3kCWuH9zoQ==","signatures":[{"sig":"MEQCICr7qenuIXU1NHXgqcG+49D0BVM7eVr4AXlwIt6BkFcUAiBGkek8VA8cQynSn2WwXfbZd6Xzg8ESvCK0pKX9gd2X1Q==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21847},"type":"module","gitHead":"72a7adcc13c4c35facd710ac7435d6cb58579ffb","scripts":{"status":"vitest run","publication-1":"npm publish --access public","status-monitor":"vitest"},"_npmUser":{"name":"bgraceful","email":"graceful.bryonics@proton.me"},"_npmVersion":"9.2.0","description":"``` State Management is: * An object singleton that is monitored for changes \t* Methods for checking if a particular change occurred to that object ```","directories":{},"_nodeVersion":"18.19.0","dependencies":{"lodash":"^4.17.21"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.0.3","jsdom":"^25.0.1","vitest":"^0.34.4"},"_npmOperationalInternal":{"tmp":"tmp/trucks_2.0.0_1740184142449_0.2017303901280605","host":"s3://npm-registry-packages-npm-production"}},"3.0.0":{"name":"@bothy/trucks","version":"3.0.0","license":"ISC","_id":"@bothy/trucks@3.0.0","maintainers":[{"name":"bgraceful","email":"graceful.bryonics@proton.me"}],"dist":{"shasum":"419983142a4009f57c433803c17f2de40668a55c","tarball":"https://registry.npmjs.org/@bothy/trucks/-/trucks-3.0.0.tgz","fileCount":13,"integrity":"sha512-GV3G2muTsqBUHeGvIOZQFzM1m86QPFqxum8FIreFKnGGLF+nebM5yVwIZxS170vyi/48tz910OYGZcrojLveQg==","signatures":[{"sig":"MEUCIBBLQGOfFSNU8JltJOfYbCaaKhQWNhxFZfkMTNmDnRb0AiEA2LtDe5irKJwi1AP3KlBX8qQHdaeBAga3YLLFIOAKXkU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":21855},"type":"module","gitHead":"8191b7ae4dd2c12920251594387e730d1d7397d9","scripts":{"status":"vitest run","publication-1":"npm publish --access public","status-monitor":"vitest"},"_npmUser":{"name":"bgraceful","email":"graceful.bryonics@proton.me"},"_npmVersion":"10.8.2","description":"``` State Management is: * An object singleton that is monitored for changes \t* Methods for checking if a particular change occurred to that object ```","directories":{},"_nodeVersion":"20.19.1","dependencies":{"lodash":"^4.17.21"},"_hasShrinkwrap":false,"devDependencies":{"vite":"^6.0.3","jsdom":"^25.0.1","vitest":"^3.1.2"},"_npmOperationalInternal":{"tmp":"tmp/trucks_3.0.0_1745639975700_0.23893127199740105","host":"s3://npm-registry-packages-npm-production"}},"4.0.0":{"name":"@bothy/trucks","version":"4.0.0","license":"ISC","main":"index.js","type":"module","devDependencies":{"jsdom":"^25.0.1","vite":"^6.0.3","vitest":"^3.1.2"},"dependencies":{"lodash":"^4.17.21"},"scripts":{"status-monitor":"vitest","status":"vitest run","publication-1":"npm publish --access public"},"_id":"@bothy/trucks@4.0.0","description":"``` State Management is: * An object singleton that is monitored for changes \t* Methods for checking if a particular change occurred to that object ```","_integrity":"sha512-yRwJUOw3VsJ0dMLPI6u0CRk7qeu9c5bymNO3HY12P5E9XEM8qf8omFzfMQ1a2uIt44YdkVtiO812Jb2+hlh8Hw==","_resolved":"/tmp/9fc290ffe100967a9d5d773310dedc52/bothy-trucks-4.0.0.tgz","_from":"file:bothy-trucks-4.0.0.tgz","_nodeVersion":"20.19.1","_npmVersion":"10.8.2","dist":{"integrity":"sha512-yRwJUOw3VsJ0dMLPI6u0CRk7qeu9c5bymNO3HY12P5E9XEM8qf8omFzfMQ1a2uIt44YdkVtiO812Jb2+hlh8Hw==","shasum":"cb21160017a2c8d9b19ebf8b4e05d8a6026bbb25","tarball":"https://registry.npmjs.org/@bothy/trucks/-/trucks-4.0.0.tgz","fileCount":14,"unpackedSize":22623,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDJ3WepzvWaeN1JwqHDAHDHGyhS1uj68LujBejTocrz0AIgGPF6eTUyF1pDn2Y1CqGHj7XMfGhuHjsCqn51ZdINZVo="}]},"_npmUser":{"name":"bgraceful","email":"graceful.bryonics@proton.me"},"directories":{},"maintainers":[{"name":"bgraceful","email":"graceful.bryonics@proton.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/trucks_4.0.0_1745790013763_0.37296263269079133"},"_hasShrinkwrap":false}},"time":{"created":"2025-02-22T00:21:54.579Z","modified":"2025-04-27T21:40:14.133Z","1.0.0":"2025-02-22T00:21:54.794Z","2.0.0":"2025-02-22T00:29:02.621Z","3.0.0":"2025-04-26T03:59:35.885Z","4.0.0":"2025-04-27T21:40:13.946Z"},"license":"ISC","description":"``` State Management is: * An object singleton that is monitored for changes \t* Methods for checking if a particular change occurred to that object ```","maintainers":[{"name":"bgraceful","email":"graceful.bryonics@proton.me"}],"readme":"\n\n\n\n# @bothy/trucks\n```\nState Management is:\n* An object singleton that is monitored for changes\n\t* Methods for checking if a particular change occurred to that object\n```\n\n## Synonyms\n```\nmonitored object, country management, union management, \nfrontend database, browser database, state executivities\n```\n\n\n## Install\n```\nnpm install @bothy/trucks\n```\n\n## Example\n```\nThis is essentially an internal component or singleton.\n\nHowever, this truck file can be imported from\nanywhere in the dapp.\n```\n\n```\nThis state manager can be used in any framework.\nHowever, here is a svelte implementation example.\nThe implementation guide can be found after.\n```\n\n```\n// $lib/trucks/truck_1/index.js\n\n\nimport { build_truck } from '@bothy/trucks'\n\nconst trucks = {}\n\n/*\n\tThis adds a truck to the trucks object as trucks [1] = ...\n\tSuch, the truck can then be deleted with the \"destroy\" method.\n*/\nexport const make = () => {\n\t\n\t/*\n\t\tFreight is the \"state\" or the object that is\n\t\tis monitored.\n\t*/\n\ttrucks [1] = build_truck ({\n\t\tfreight: {\n\t\t\tleaf_name: \"Leaf 1\",\n\t\t\tleaves: {\n\t\t\t\t\"Leaf 1\": {\n\t\t\t\t\talert_note: \"This is leaf 1.\",\n\t\t\t\t\talert_success: \"\",\n\t\t\t\t\talert_problem_1: \"\",\n\t\t\t\t\talert_problem_2: \"\"\t\n\t\t\t\t},\n\t\t\t\t\"Leaf 2\": {\n\t\t\t\t\talert_note: \"waiting for the flourish\",\n\t\t\t\t\talert_success: \"\",\n\t\t\t\t\talert_problem_1: \"\",\n\t\t\t\t\talert_problem_2: \"\"\t\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n\t\n\t/*\n\t\tChanges to the freight can be monitored here:\n\t\t\n\t\t\t* \toriginal_freight: \n\t\t\t\t\tis the \"freight\" object that was passed to:\n\t\t\t\t\tbuild_truck ({ freight });\n\n\t\t\t* \tpro_freight:\n\t\t\t\t\tis the proxy object that encapsulates\n\t\t\t\t\tthe original_freight for monitoring purposes.\n\t\t\t\n\t\t\t* \tbracket: the bracket or sub-bracket where the change occurred.\n\t\t\t\n\t\t\t* \tproperty: the property that changed\n\t\t\t* \tvalue: the value that changed\n\t*/\n\tlet monitor = trucks [1].monitor (async ({\n\t\toriginal_freight,\n\t\tpro_freight, \n\t\t//\n\t\tbracket,\n\t\t//\n\t\tproperty, \n\t\tvalue\n\t}) => {\n\t\ttry {\n\t\t\t// leaf name changed\n\t\t\tif (bracket === original_freight && property === \"leaf_name\") {\n\t\t\t\tconsole.info (\"leaf name changed\");\n\t\t\t}\n\t\t\t\n\t\t\t// Leaf 1 alert_success changed\n\t\t\tif (bracket === original_freight.leaves [\"Leaf 1\"] && property === \"alert_success\") {\n\t\t\t\tconsole.info (\"Leaf 1 alert_success changed.\");\n\t\t\t}\n\t\t}\n\t\tcatch (imperfection) {\n\t\t\tconsole.error (imperfection);\n\t\t}\n\t});\n}\n\nexport const destroy = () => {\n\tdelete trucks [1];\n}\n\nexport const retrieve = () => {\n\treturn trucks [1];\n}\n\n\n/*\n\tChanges to the freight can also be monitored like this.\n\tThis adds another monitor each time \"monitor\" is called.\n\t\n\tAn example implementation can be found below.\n*/\nexport const monitor = (action) => {\t\n\treturn trucks [1].monitor (envelope => { action (envelope); });\n}\n```\n\n\n\n\n## Make and Destroy of \"Truck 1\" in a root component (Svelte Example) \nThis is a Svelte example, but this can really be\nused in any framework.\n\n```\n// Regions/Parador/Lot.svelte\n\nimport { onMount, onDestroy } from 'svelte'\nimport * as Truck_1 from '$lib/trucks/truck_1/index.js'\n\nonMount (async () => {\t\n\tTruck_1.make ()\n});\nonDestroy (() => {\n\tTruck_1.destroy ()\n});\n```\n\n\n## Monitor and Monitor Stop in nested component.\n```\nIf \"Truck_1_Freight\" is modified anywhere, the modification\nis going to be noticed by each \"monitor\".\n```\n```\n// Regions/Parador/Locations/Veranda.svelte\n\nimport { onMount, onDestroy } from 'svelte'\nimport * as Truck_1 from '$lib/trucks/truck_1/index.js'\n\nlet Truck_1_Monitor;\nlet Truck_1_Freight;\nonMount (async () => {\n\tTruck_1_Freight = Truck_1.retrieve ().pro_freight; \n\t\n\tTruck_1_Monitor = Truck_1.monitor (async ({\n\t\toriginal_freight,\n\t\tpro_freight, \n\t\t//\n\t\ttarget,\n\t\t//\n\t\tproperty, \n\t\tvalue\n\t}) => {\n\t\ttry {\n\t\t\t// watch for changes to leaf_name\n\t\t\tif (target === original_freight && property === \"leaf_name\") {\n\t\t\t\tconsole.info (\"leaf name changed\");\n\t\t\t\t\n\t\t\t}\n\t\t}\n\t\tcatch (imperfection) {\n\t\t\tconsole.error (imperfection);\n\t\t}\n\t});\n\t\n\t\n\t//\n\t//\tThis updates \"leaf_name\" and alerts each\n\t//\tmonitor.\n\t//\n\tTruck_1_Freight.leaf_name = \"Leaf 2\"\n});\n\nonDestroy (() => {\n\tTruck_1_Monitor.stop ()\n}); \n\n```\n\n\n\n\n\n## Monitor and Monitor Stop\n### Svelte Truck_1 Singleton Component\n```\nThis is an easier method of adding a monitor to a component with svelte.\n```\n```\n/*\n\timport * as Truck_1 from '$lib/trucks/truck_1/index.js'\n\timport Truck_1_Ride from '$lib/trucks/truck_1/Ride.svelte'\n\tlet Truck_1_Freight = false\n\n\t<Truck_1_Ride on_change={ ({ pro_freight }) => { Truck_1_Freight = pro_freight; } } />\n\t{#if typeof Truck_1_Freight === \"object\"}\n\t\n\t{/if}\n*/\n\n/*\n\thappening = \"mounted\"\n\thappening = \"modulated\"\n*/\nimport { onMount, onDestroy } from 'svelte'\nimport { monitor_truck, retrieve_truck } from './index.js'\n\nexport let on_change = () => {}\n\nlet Truck_Monitor;\nonMount (async () => {\n\tTruck_Monitor = monitor_truck (({ pro_freight }) => {\n\t\ton_change ({ \n\t\t\tpro_freight, \n\t\t\thappening: \"modulated\" \n\t\t})\n\t})\n\t\n\ton_change ({ \n\t\tpro_freight: retrieve_truck ().pro_freight, \n\t\thappening: \"mounted\" \n\t})\n});\nonDestroy (() => {\n\tTruck_Monitor.stop ()\n});\n\n\n</script>\n\n<div style=\"position: absolute\"></div>\n```\n\n\n\n","readmeFilename":"readme.md"}