{"_id":"@_agco/understated","_rev":"1-e4f597264650cbab2abf50731ebacd7d","name":"@_agco/understated","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@_agco/understated","version":"1.0.1","description":"simple state management and caching library","main":"index.js","license":"MIT","repository":{"type":"git","url":"git+https://bitbucket.org/_agco/understated.js.git"},"authors":[{"name":"Ajay Gupta","email":"hi@ajaygupta.co","url":"https://ajaygupta.co"}],"scripts":{"release":"grunt"},"devDependencies":{"@babel/core":"^7.2.2","@babel/preset-env":"^7.2.3","grunt":"^1.0.3","grunt-babel":"^8.0.0","jshint":"^2.9.7","load-grunt-tasks":"^4.0.0"},"keywords":["state","management","data","store","caching"],"publishConfig":{"access":"public"},"gitHead":"28f401291367982b3bbecd2a6213495452782b5e","homepage":"https://bitbucket.org/_agco/understated.js#readme","_id":"@_agco/understated@1.0.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-2sRmDTPwT35x/N0cPIPB+PV8T7H7Qy9wKgY2f26s8l0v3/aFwVzSuQT96tpowGaR8A9zivlI2+BtNSs65s1ZIg==","shasum":"aa71b985b4a1862c017b289f28f5a9a123699dfb","tarball":"https://registry.npmjs.org/@_agco/understated/-/understated-1.0.1.tgz","fileCount":5,"unpackedSize":20247,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdXvW/CRA9TVsSAnZWagAAvygQAJmGXrjeIk0RflzmEs4v\nhjErf344IALmIG9+PCPDGUtGUwrKTZEEYZvExvSIXqjFgy2EexK8q0dPoCyL\nNwnVZWRy6rpnqGVR+Gmjck/5WPRMxVcENVwzqS3lSNNyulbJC2pSCzLnclAm\n6g5ZBV1gw1YTZhsi9rUIXhl2S4MssgqE99bFhMz5dGK0aEfuO3DWpQJIG7xD\nUsPBZzHL+Du8YG8ZdVGMZU0J/aeNt3dvoxlFx2fkv+W9nomFHyCLiJhCN1ai\n/J0m8YFEcUDTrSEwLttpSwCP9PciFuxpvjK+nJzs+2o2BHnhPI3xy5bkCbJ7\nqEvjr/2LoGFjUrDxJKW4WGImiCIb+o/5qpxp2dAhgmlcULFatq3uB0iGtYV5\nLGE4ouUpQld9oJ8sNfMqUmO/bBD5wKW2gC03Zf4E+IL3rcK57XcO/OFP33tV\nZ+WKwNIDlmmDFoIQTzDqS1AYsY6IIoKYjA+NA83WO2WT4d77uogLhbwD4y+F\nRpwHWQMKbLNuCRFF5Z6arx+TDqGMwaj1lwk8lIRxNnlGCOy1+870QGI8cwVn\nccUcPz1sKeeLvIqT5d/c9yVEwBeWlRsy0IIC+JsWr3oJF0QmJVjM4N/z8VBc\nnVFFQmW3926lT4UrA+KNq3y8/lpDqSljTzhNeDjLIP31I9fc53vgEmnVmNkL\n69zk\r\n=vtmX\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDkXbQl2g35ncKitlkUl3sANdZ9hHRpg6PG7y6XPKXW4QIgaSXy7X6NkJlVhjQEh8oMf/Xh12jT+5kDJ4aVZiMsmjk="}]},"maintainers":[{"name":"_ajaygupta","email":"hi@ajaygupta.co"}],"_npmUser":{"name":"_ajaygupta","email":"hi@ajaygupta.co"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/understated_1.0.1_1566504382795_0.013240474834385063"},"_hasShrinkwrap":false}},"time":{"created":"2019-08-22T20:06:22.605Z","1.0.1":"2019-08-22T20:06:22.924Z","modified":"2022-04-04T10:51:26.247Z"},"maintainers":[{"name":"_ajaygupta","email":"hi@ajaygupta.co"}],"description":"simple state management and caching library","homepage":"https://bitbucket.org/_agco/understated.js#readme","keywords":["state","management","data","store","caching"],"repository":{"type":"git","url":"git+https://bitbucket.org/_agco/understated.js.git"},"license":"MIT","readme":"# understated.js\n\nA Predictable Promise based data store, caching and state management library for web and native platforms.\n\n## Usage\n\nThe library exposes simple APIs for data manipulation and management:\n\n---\n\n### get(key: string OR array)\n\n- This method provides read-access to the state container.\n- Use it to get a snapshot of the whole state object or specific state properties by passing the `key` as a parameter.\n- The `key` parameter can either be a string or an array of keys.\n- It returns a promise, and the successful response is a snapshot of the requested data.\n\n```js\n// Get a snapshot of the whole state container\nstate.get().then(state => {\n  // statements\n});\n```\n\n```js\n// Get a snapshot of a specific\n// property from the state container\nstate.get(\"todos\").then(todos => {\n  // statements\n});\n```\n\n```js\n// Get a snapshot of multiple\n// properties from the state container\nstate.get([\"todo1\", \"todo2\", \"todoN\"]).then(todos => {\n  // statements\n});\n```\n\n---\n\n### update(key: string OR array: required, payload: any)\n\n- This method provides write-access to the state container.\n- Use it to write data in the state container.\n- The `key` parameter can either be a string or an array of objects (`{ key, payload }`) where key is required.\n- If an already existing property is passed as the `key`, then it gets overwritten with the new value i.e. the `payload`.\n- It returns a promise, and the successful response is a snapshot of the updated state.\n\n```js\n// Add a property to the state container\nstate.update(\"amount\", 10000).then(newstate => {\n  // statements\n});\n```\n\n```js\n// Add multiple properties to the state container\nstate\n  .update([\n    { key: \"todo1\", payload: \"buy grocery\" },\n    { key: \"todo2\", payload: \"dinner with mom\" }\n  ])\n  .then(newstate => {\n    // statements\n  });\n```\n\n---\n\n### remove(key: string OR regex: required)\n\n- This method provides write-access to the state container.\n- Use it to remove one or more properties by passing the `key` as a parameter.\n- It returns a promise, and the successful response is a snapshot of the updated state.\n\n```js\n// Remove a specific property\n// from the state conatainer\nstate.remove(\"todo\").then(newstate => {\n  // statements\n});\n\n// Remove multiple properties\n// from the state conatainer using regex\nstate.remove(/todo_i/).then(newstate => {\n  // statements\n});\n```\n\n---\n\n### reset()\n\n- This method provides write-access to the state container.\n- Use it to empty or reset the state container.\n\n```js\n// Empty the state container\nstate.reset(); // returns state = {}\n```\n\n---\n\n### has(key: string: required)\n\n- This method provides read-access to the state container.\n- Use it to check whether a property exists in the state container.\n- It returns the value of the property if it exists, otherwise, returns false.\n\n```js\n// Check whether a specific property\n// exists in the state container\nstate.has(\"todo\"); // returns {...} or false\n```\n\n---\n\n### subscribe(callback: function: required, shouldExecuteImmediately: bool)\n\n- This method registers a callback which will be exectued whenever the state is mutated.\n- Use this method to subscribe to state mutations.\n- `shouldExecuteImmediately`, if passed as `true`, then the callback will be immediately executed when `subscribe` is called.\n\n```js\n// assign a method which will be\n// called everytime the state is mutated.\nstate.subscribe(render);\n```\n\n---\n\n### history()\n\n- This method returns the history of all the state mutations since initialization.\n\n```js\n// return the history of state mutations\nstate.history();\n```\n","readmeFilename":"README.md"}